babylon.d.txt 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073
  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 current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vecto3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param transform defines the transform (view x projection) matrix to use
  1851. * @returns the new Vector3
  1852. */
  1853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param view defines the view matrix to use
  1861. * @param projection defines the projection matrix to use
  1862. * @returns the new Vector3
  1863. */
  1864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1865. /**
  1866. * Unproject from screen space to object space
  1867. * @param source defines the screen space Vector3 to use
  1868. * @param viewportWidth defines the current width of the viewport
  1869. * @param viewportHeight defines the current height of the viewport
  1870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1871. * @param view defines the view matrix to use
  1872. * @param projection defines the projection matrix to use
  1873. * @param result defines the Vector3 where to store the result
  1874. */
  1875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1876. /**
  1877. * Unproject from screen space to object space
  1878. * @param sourceX defines the screen space x coordinate to use
  1879. * @param sourceY defines the screen space y coordinate to use
  1880. * @param sourceZ defines the screen space z coordinate to use
  1881. * @param viewportWidth defines the current width of the viewport
  1882. * @param viewportHeight defines the current height of the viewport
  1883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1884. * @param view defines the view matrix to use
  1885. * @param projection defines the projection matrix to use
  1886. * @param result defines the Vector3 where to store the result
  1887. */
  1888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1889. /**
  1890. * Gets the minimal coordinate values between two Vector3
  1891. * @param left defines the first operand
  1892. * @param right defines the second operand
  1893. * @returns the new Vector3
  1894. */
  1895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1896. /**
  1897. * Gets the maximal coordinate values between two Vector3
  1898. * @param left defines the first operand
  1899. * @param right defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Returns the distance between the vectors "value1" and "value2"
  1905. * @param value1 defines the first operand
  1906. * @param value2 defines the second operand
  1907. * @returns the distance
  1908. */
  1909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1910. /**
  1911. * Returns the squared distance between the vectors "value1" and "value2"
  1912. * @param value1 defines the first operand
  1913. * @param value2 defines the second operand
  1914. * @returns the squared distance
  1915. */
  1916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1917. /**
  1918. * Returns a new Vector3 located at the center between "value1" and "value2"
  1919. * @param value1 defines the first operand
  1920. * @param value2 defines the second operand
  1921. * @returns the new Vector3
  1922. */
  1923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1924. /**
  1925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1927. * to something in order to rotate it from its local system to the given target system
  1928. * Note: axis1, axis2 and axis3 are normalized during this operation
  1929. * @param axis1 defines the first axis
  1930. * @param axis2 defines the second axis
  1931. * @param axis3 defines the third axis
  1932. * @returns a new Vector3
  1933. */
  1934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1935. /**
  1936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1937. * @param axis1 defines the first axis
  1938. * @param axis2 defines the second axis
  1939. * @param axis3 defines the third axis
  1940. * @param ref defines the Vector3 where to store the result
  1941. */
  1942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1943. }
  1944. /**
  1945. * Vector4 class created for EulerAngle class conversion to Quaternion
  1946. */
  1947. export class Vector4 {
  1948. /** x value of the vector */
  1949. x: number;
  1950. /** y value of the vector */
  1951. y: number;
  1952. /** z value of the vector */
  1953. z: number;
  1954. /** w value of the vector */
  1955. w: number;
  1956. /**
  1957. * Creates a Vector4 object from the given floats.
  1958. * @param x x value of the vector
  1959. * @param y y value of the vector
  1960. * @param z z value of the vector
  1961. * @param w w value of the vector
  1962. */
  1963. constructor(
  1964. /** x value of the vector */
  1965. x: number,
  1966. /** y value of the vector */
  1967. y: number,
  1968. /** z value of the vector */
  1969. z: number,
  1970. /** w value of the vector */
  1971. w: number);
  1972. /**
  1973. * Returns the string with the Vector4 coordinates.
  1974. * @returns a string containing all the vector values
  1975. */
  1976. toString(): string;
  1977. /**
  1978. * Returns the string "Vector4".
  1979. * @returns "Vector4"
  1980. */
  1981. getClassName(): string;
  1982. /**
  1983. * Returns the Vector4 hash code.
  1984. * @returns a unique hash code
  1985. */
  1986. getHashCode(): number;
  1987. /**
  1988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1989. * @returns the resulting array
  1990. */
  1991. asArray(): number[];
  1992. /**
  1993. * Populates the given array from the given index with the Vector4 coordinates.
  1994. * @param array array to populate
  1995. * @param index index of the array to start at (default: 0)
  1996. * @returns the Vector4.
  1997. */
  1998. toArray(array: FloatArray, index?: number): Vector4;
  1999. /**
  2000. * Adds the given vector to the current Vector4.
  2001. * @param otherVector the vector to add
  2002. * @returns the updated Vector4.
  2003. */
  2004. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2005. /**
  2006. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2007. * @param otherVector the vector to add
  2008. * @returns the resulting vector
  2009. */
  2010. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2011. /**
  2012. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2013. * @param otherVector the vector to add
  2014. * @param result the vector to store the result
  2015. * @returns the current Vector4.
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2018. /**
  2019. * Subtract in place the given vector from the current Vector4.
  2020. * @param otherVector the vector to subtract
  2021. * @returns the updated Vector4.
  2022. */
  2023. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2024. /**
  2025. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2026. * @param otherVector the vector to add
  2027. * @returns the new vector with the result
  2028. */
  2029. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2030. /**
  2031. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2032. * @param otherVector the vector to subtract
  2033. * @param result the vector to store the result
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2039. */
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. * @param x value to subtract
  2043. * @param y value to subtract
  2044. * @param z value to subtract
  2045. * @param w value to subtract
  2046. * @returns new vector containing the result
  2047. */
  2048. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2049. /**
  2050. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2051. * @param x value to subtract
  2052. * @param y value to subtract
  2053. * @param z value to subtract
  2054. * @param w value to subtract
  2055. * @param result the vector to store the result in
  2056. * @returns the current Vector4.
  2057. */
  2058. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2059. /**
  2060. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2061. * @returns a new vector with the negated values
  2062. */
  2063. negate(): Vector4;
  2064. /**
  2065. * Multiplies the current Vector4 coordinates by scale (float).
  2066. * @param scale the number to scale with
  2067. * @returns the updated Vector4.
  2068. */
  2069. scaleInPlace(scale: number): Vector4;
  2070. /**
  2071. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2072. * @param scale the number to scale with
  2073. * @returns a new vector with the result
  2074. */
  2075. scale(scale: number): Vector4;
  2076. /**
  2077. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2078. * @param scale the number to scale with
  2079. * @param result a vector to store the result in
  2080. * @returns the current Vector4.
  2081. */
  2082. scaleToRef(scale: number, result: Vector4): Vector4;
  2083. /**
  2084. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2085. * @param scale defines the scale factor
  2086. * @param result defines the Vector4 object where to store the result
  2087. * @returns the unmodified current Vector4
  2088. */
  2089. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2090. /**
  2091. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2092. * @param otherVector the vector to compare against
  2093. * @returns true if they are equal
  2094. */
  2095. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2096. /**
  2097. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2098. * @param otherVector vector to compare against
  2099. * @param epsilon (Default: very small number)
  2100. * @returns true if they are equal
  2101. */
  2102. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2103. /**
  2104. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2105. * @param x x value to compare against
  2106. * @param y y value to compare against
  2107. * @param z z value to compare against
  2108. * @param w w value to compare against
  2109. * @returns true if equal
  2110. */
  2111. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2112. /**
  2113. * Multiplies in place the current Vector4 by the given one.
  2114. * @param otherVector vector to multiple with
  2115. * @returns the updated Vector4.
  2116. */
  2117. multiplyInPlace(otherVector: Vector4): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2120. * @param otherVector vector to multiple with
  2121. * @returns resulting new vector
  2122. */
  2123. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2126. * @param otherVector vector to multiple with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2133. * @param x x value multiply with
  2134. * @param y y value multiply with
  2135. * @param z z value multiply with
  2136. * @param w w value multiply with
  2137. * @returns resulting new vector
  2138. */
  2139. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2142. * @param otherVector vector to devide with
  2143. * @returns resulting new vector
  2144. */
  2145. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2146. /**
  2147. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2148. * @param otherVector vector to devide with
  2149. * @param result vector to store the result
  2150. * @returns the current Vector4.
  2151. */
  2152. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2153. /**
  2154. * Divides the current Vector3 coordinates by the given ones.
  2155. * @param otherVector vector to devide with
  2156. * @returns the updated Vector3.
  2157. */
  2158. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2159. /**
  2160. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2161. * @param other defines the second operand
  2162. * @returns the current updated Vector4
  2163. */
  2164. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2165. /**
  2166. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2167. * @param other defines the second operand
  2168. * @returns the current updated Vector4
  2169. */
  2170. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2171. /**
  2172. * Gets a new Vector4 from current Vector4 floored values
  2173. * @returns a new Vector4
  2174. */
  2175. floor(): Vector4;
  2176. /**
  2177. * Gets a new Vector4 from current Vector3 floored values
  2178. * @returns a new Vector4
  2179. */
  2180. fract(): Vector4;
  2181. /**
  2182. * Returns the Vector4 length (float).
  2183. * @returns the length
  2184. */
  2185. length(): number;
  2186. /**
  2187. * Returns the Vector4 squared length (float).
  2188. * @returns the length squared
  2189. */
  2190. lengthSquared(): number;
  2191. /**
  2192. * Normalizes in place the Vector4.
  2193. * @returns the updated Vector4.
  2194. */
  2195. normalize(): Vector4;
  2196. /**
  2197. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2198. * @returns this converted to a new vector3
  2199. */
  2200. toVector3(): Vector3;
  2201. /**
  2202. * Returns a new Vector4 copied from the current one.
  2203. * @returns the new cloned vector
  2204. */
  2205. clone(): Vector4;
  2206. /**
  2207. * Updates the current Vector4 with the given one coordinates.
  2208. * @param source the source vector to copy from
  2209. * @returns the updated Vector4.
  2210. */
  2211. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2212. /**
  2213. * Updates the current Vector4 coordinates with the given floats.
  2214. * @param x float to copy from
  2215. * @param y float to copy from
  2216. * @param z float to copy from
  2217. * @param w float to copy from
  2218. * @returns the updated Vector4.
  2219. */
  2220. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2221. /**
  2222. * Updates the current Vector4 coordinates with the given floats.
  2223. * @param x float to set from
  2224. * @param y float to set from
  2225. * @param z float to set from
  2226. * @param w float to set from
  2227. * @returns the updated Vector4.
  2228. */
  2229. set(x: number, y: number, z: number, w: number): Vector4;
  2230. /**
  2231. * Copies the given float to the current Vector3 coordinates
  2232. * @param v defines the x, y, z and w coordinates of the operand
  2233. * @returns the current updated Vector3
  2234. */
  2235. setAll(v: number): Vector4;
  2236. /**
  2237. * Returns a new Vector4 set from the starting index of the given array.
  2238. * @param array the array to pull values from
  2239. * @param offset the offset into the array to start at
  2240. * @returns the new vector
  2241. */
  2242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2243. /**
  2244. * Updates the given vector "result" from the starting index of the given array.
  2245. * @param array the array to pull values from
  2246. * @param offset the offset into the array to start at
  2247. * @param result the vector to store the result in
  2248. */
  2249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2250. /**
  2251. * Updates the given vector "result" from the starting index of the given Float32Array.
  2252. * @param array the array to pull values from
  2253. * @param offset the offset into the array to start at
  2254. * @param result the vector to store the result in
  2255. */
  2256. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2257. /**
  2258. * Updates the given vector "result" coordinates from the given floats.
  2259. * @param x float to set from
  2260. * @param y float to set from
  2261. * @param z float to set from
  2262. * @param w float to set from
  2263. * @param result the vector to the floats in
  2264. */
  2265. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2266. /**
  2267. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2268. * @returns the new vector
  2269. */
  2270. static Zero(): Vector4;
  2271. /**
  2272. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2273. * @returns the new vector
  2274. */
  2275. static One(): Vector4;
  2276. /**
  2277. * Returns a new normalized Vector4 from the given one.
  2278. * @param vector the vector to normalize
  2279. * @returns the vector
  2280. */
  2281. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Updates the given vector "result" from the normalization of the given one.
  2284. * @param vector the vector to normalize
  2285. * @param result the vector to store the result in
  2286. */
  2287. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2288. /**
  2289. * Returns a vector with the minimum values from the left and right vectors
  2290. * @param left left vector to minimize
  2291. * @param right right vector to minimize
  2292. * @returns a new vector with the minimum of the left and right vector values
  2293. */
  2294. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2295. /**
  2296. * Returns a vector with the maximum values from the left and right vectors
  2297. * @param left left vector to maximize
  2298. * @param right right vector to maximize
  2299. * @returns a new vector with the maximum of the left and right vector values
  2300. */
  2301. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns the distance (float) between the vectors "value1" and "value2".
  2304. * @param value1 value to calulate the distance between
  2305. * @param value2 value to calulate the distance between
  2306. * @return the distance between the two vectors
  2307. */
  2308. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2309. /**
  2310. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2311. * @param value1 value to calulate the distance between
  2312. * @param value2 value to calulate the distance between
  2313. * @return the distance between the two vectors squared
  2314. */
  2315. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2316. /**
  2317. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2318. * @param value1 value to calulate the center between
  2319. * @param value2 value to calulate the center between
  2320. * @return the center between the two vectors
  2321. */
  2322. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2323. /**
  2324. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2325. * This methods computes transformed normalized direction vectors only.
  2326. * @param vector the vector to transform
  2327. * @param transformation the transformation matrix to apply
  2328. * @returns the new vector
  2329. */
  2330. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2331. /**
  2332. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2333. * This methods computes transformed normalized direction vectors only.
  2334. * @param vector the vector to transform
  2335. * @param transformation the transformation matrix to apply
  2336. * @param result the vector to store the result in
  2337. */
  2338. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2339. /**
  2340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2341. * This methods computes transformed normalized direction vectors only.
  2342. * @param x value to transform
  2343. * @param y value to transform
  2344. * @param z value to transform
  2345. * @param w value to transform
  2346. * @param transformation the transformation matrix to apply
  2347. * @param result the vector to store the results in
  2348. */
  2349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2350. /**
  2351. * Creates a new Vector4 from a Vector3
  2352. * @param source defines the source data
  2353. * @param w defines the 4th component (default is 0)
  2354. * @returns a new Vector4
  2355. */
  2356. static FromVector3(source: Vector3, w?: number): Vector4;
  2357. }
  2358. /**
  2359. * Interface for the size containing width and height
  2360. */
  2361. export interface ISize {
  2362. /**
  2363. * Width
  2364. */
  2365. width: number;
  2366. /**
  2367. * Heighht
  2368. */
  2369. height: number;
  2370. }
  2371. /**
  2372. * Size containing widht and height
  2373. */
  2374. export class Size implements ISize {
  2375. /**
  2376. * Width
  2377. */
  2378. width: number;
  2379. /**
  2380. * Height
  2381. */
  2382. height: number;
  2383. /**
  2384. * Creates a Size object from the given width and height (floats).
  2385. * @param width width of the new size
  2386. * @param height height of the new size
  2387. */
  2388. constructor(width: number, height: number);
  2389. /**
  2390. * Returns a string with the Size width and height
  2391. * @returns a string with the Size width and height
  2392. */
  2393. toString(): string;
  2394. /**
  2395. * "Size"
  2396. * @returns the string "Size"
  2397. */
  2398. getClassName(): string;
  2399. /**
  2400. * Returns the Size hash code.
  2401. * @returns a hash code for a unique width and height
  2402. */
  2403. getHashCode(): number;
  2404. /**
  2405. * Updates the current size from the given one.
  2406. * @param src the given size
  2407. */
  2408. copyFrom(src: Size): void;
  2409. /**
  2410. * Updates in place the current Size from the given floats.
  2411. * @param width width of the new size
  2412. * @param height height of the new size
  2413. * @returns the updated Size.
  2414. */
  2415. copyFromFloats(width: number, height: number): Size;
  2416. /**
  2417. * Updates in place the current Size from the given floats.
  2418. * @param width width to set
  2419. * @param height height to set
  2420. * @returns the updated Size.
  2421. */
  2422. set(width: number, height: number): Size;
  2423. /**
  2424. * Multiplies the width and height by numbers
  2425. * @param w factor to multiple the width by
  2426. * @param h factor to multiple the height by
  2427. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2428. */
  2429. multiplyByFloats(w: number, h: number): Size;
  2430. /**
  2431. * Clones the size
  2432. * @returns a new Size copied from the given one.
  2433. */
  2434. clone(): Size;
  2435. /**
  2436. * True if the current Size and the given one width and height are strictly equal.
  2437. * @param other the other size to compare against
  2438. * @returns True if the current Size and the given one width and height are strictly equal.
  2439. */
  2440. equals(other: Size): boolean;
  2441. /**
  2442. * The surface of the Size : width * height (float).
  2443. */
  2444. readonly surface: number;
  2445. /**
  2446. * Create a new size of zero
  2447. * @returns a new Size set to (0.0, 0.0)
  2448. */
  2449. static Zero(): Size;
  2450. /**
  2451. * Sums the width and height of two sizes
  2452. * @param otherSize size to add to this size
  2453. * @returns a new Size set as the addition result of the current Size and the given one.
  2454. */
  2455. add(otherSize: Size): Size;
  2456. /**
  2457. * Subtracts the width and height of two
  2458. * @param otherSize size to subtract to this size
  2459. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2460. */
  2461. subtract(otherSize: Size): Size;
  2462. /**
  2463. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2464. * @param start starting size to lerp between
  2465. * @param end end size to lerp between
  2466. * @param amount amount to lerp between the start and end values
  2467. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2468. */
  2469. static Lerp(start: Size, end: Size, amount: number): Size;
  2470. }
  2471. /**
  2472. * Class used to store quaternion data
  2473. * @see https://en.wikipedia.org/wiki/Quaternion
  2474. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2475. */
  2476. export class Quaternion {
  2477. /** defines the first component (0 by default) */
  2478. x: number;
  2479. /** defines the second component (0 by default) */
  2480. y: number;
  2481. /** defines the third component (0 by default) */
  2482. z: number;
  2483. /** defines the fourth component (1.0 by default) */
  2484. w: number;
  2485. /**
  2486. * Creates a new Quaternion from the given floats
  2487. * @param x defines the first component (0 by default)
  2488. * @param y defines the second component (0 by default)
  2489. * @param z defines the third component (0 by default)
  2490. * @param w defines the fourth component (1.0 by default)
  2491. */
  2492. constructor(
  2493. /** defines the first component (0 by default) */
  2494. x?: number,
  2495. /** defines the second component (0 by default) */
  2496. y?: number,
  2497. /** defines the third component (0 by default) */
  2498. z?: number,
  2499. /** defines the fourth component (1.0 by default) */
  2500. w?: number);
  2501. /**
  2502. * Gets a string representation for the current quaternion
  2503. * @returns a string with the Quaternion coordinates
  2504. */
  2505. toString(): string;
  2506. /**
  2507. * Gets the class name of the quaternion
  2508. * @returns the string "Quaternion"
  2509. */
  2510. getClassName(): string;
  2511. /**
  2512. * Gets a hash code for this quaternion
  2513. * @returns the quaternion hash code
  2514. */
  2515. getHashCode(): number;
  2516. /**
  2517. * Copy the quaternion to an array
  2518. * @returns a new array populated with 4 elements from the quaternion coordinates
  2519. */
  2520. asArray(): number[];
  2521. /**
  2522. * Check if two quaternions are equals
  2523. * @param otherQuaternion defines the second operand
  2524. * @return true if the current quaternion and the given one coordinates are strictly equals
  2525. */
  2526. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2527. /**
  2528. * Clone the current quaternion
  2529. * @returns a new quaternion copied from the current one
  2530. */
  2531. clone(): Quaternion;
  2532. /**
  2533. * Copy a quaternion to the current one
  2534. * @param other defines the other quaternion
  2535. * @returns the updated current quaternion
  2536. */
  2537. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2538. /**
  2539. * Updates the current quaternion with the given float coordinates
  2540. * @param x defines the x coordinate
  2541. * @param y defines the y coordinate
  2542. * @param z defines the z coordinate
  2543. * @param w defines the w coordinate
  2544. * @returns the updated current quaternion
  2545. */
  2546. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2547. /**
  2548. * Updates the current quaternion from the given float coordinates
  2549. * @param x defines the x coordinate
  2550. * @param y defines the y coordinate
  2551. * @param z defines the z coordinate
  2552. * @param w defines the w coordinate
  2553. * @returns the updated current quaternion
  2554. */
  2555. set(x: number, y: number, z: number, w: number): Quaternion;
  2556. /**
  2557. * Adds two quaternions
  2558. * @param other defines the second operand
  2559. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2560. */
  2561. add(other: DeepImmutable<Quaternion>): Quaternion;
  2562. /**
  2563. * Add a quaternion to the current one
  2564. * @param other defines the quaternion to add
  2565. * @returns the current quaternion
  2566. */
  2567. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2568. /**
  2569. * Subtract two quaternions
  2570. * @param other defines the second operand
  2571. * @returns a new quaternion as the subtraction result of the given one from the current one
  2572. */
  2573. subtract(other: Quaternion): Quaternion;
  2574. /**
  2575. * Multiplies the current quaternion by a scale factor
  2576. * @param value defines the scale factor
  2577. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2578. */
  2579. scale(value: number): Quaternion;
  2580. /**
  2581. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2582. * @param scale defines the scale factor
  2583. * @param result defines the Quaternion object where to store the result
  2584. * @returns the unmodified current quaternion
  2585. */
  2586. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2587. /**
  2588. * Multiplies in place the current quaternion by a scale factor
  2589. * @param value defines the scale factor
  2590. * @returns the current modified quaternion
  2591. */
  2592. scaleInPlace(value: number): Quaternion;
  2593. /**
  2594. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2595. * @param scale defines the scale factor
  2596. * @param result defines the Quaternion object where to store the result
  2597. * @returns the unmodified current quaternion
  2598. */
  2599. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2600. /**
  2601. * Multiplies two quaternions
  2602. * @param q1 defines the second operand
  2603. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2604. */
  2605. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2606. /**
  2607. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2608. * @param q1 defines the second operand
  2609. * @param result defines the target quaternion
  2610. * @returns the current quaternion
  2611. */
  2612. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2613. /**
  2614. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2615. * @param q1 defines the second operand
  2616. * @returns the currentupdated quaternion
  2617. */
  2618. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2619. /**
  2620. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2621. * @param ref defines the target quaternion
  2622. * @returns the current quaternion
  2623. */
  2624. conjugateToRef(ref: Quaternion): Quaternion;
  2625. /**
  2626. * Conjugates in place (1-q) the current quaternion
  2627. * @returns the current updated quaternion
  2628. */
  2629. conjugateInPlace(): Quaternion;
  2630. /**
  2631. * Conjugates in place (1-q) the current quaternion
  2632. * @returns a new quaternion
  2633. */
  2634. conjugate(): Quaternion;
  2635. /**
  2636. * Gets length of current quaternion
  2637. * @returns the quaternion length (float)
  2638. */
  2639. length(): number;
  2640. /**
  2641. * Normalize in place the current quaternion
  2642. * @returns the current updated quaternion
  2643. */
  2644. normalize(): Quaternion;
  2645. /**
  2646. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2647. * @param order is a reserved parameter and is ignore for now
  2648. * @returns a new Vector3 containing the Euler angles
  2649. */
  2650. toEulerAngles(order?: string): Vector3;
  2651. /**
  2652. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2653. * @param result defines the vector which will be filled with the Euler angles
  2654. * @param order is a reserved parameter and is ignore for now
  2655. * @returns the current unchanged quaternion
  2656. */
  2657. toEulerAnglesToRef(result: Vector3): Quaternion;
  2658. /**
  2659. * Updates the given rotation matrix with the current quaternion values
  2660. * @param result defines the target matrix
  2661. * @returns the current unchanged quaternion
  2662. */
  2663. toRotationMatrix(result: Matrix): Quaternion;
  2664. /**
  2665. * Updates the current quaternion from the given rotation matrix values
  2666. * @param matrix defines the source matrix
  2667. * @returns the current updated quaternion
  2668. */
  2669. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2670. /**
  2671. * Creates a new quaternion from a rotation matrix
  2672. * @param matrix defines the source matrix
  2673. * @returns a new quaternion created from the given rotation matrix values
  2674. */
  2675. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2676. /**
  2677. * Updates the given quaternion with the given rotation matrix values
  2678. * @param matrix defines the source matrix
  2679. * @param result defines the target quaternion
  2680. */
  2681. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2682. /**
  2683. * Returns the dot product (float) between the quaternions "left" and "right"
  2684. * @param left defines the left operand
  2685. * @param right defines the right operand
  2686. * @returns the dot product
  2687. */
  2688. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2689. /**
  2690. * Checks if the two quaternions are close to each other
  2691. * @param quat0 defines the first quaternion to check
  2692. * @param quat1 defines the second quaternion to check
  2693. * @returns true if the two quaternions are close to each other
  2694. */
  2695. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2696. /**
  2697. * Creates an empty quaternion
  2698. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2699. */
  2700. static Zero(): Quaternion;
  2701. /**
  2702. * Inverse a given quaternion
  2703. * @param q defines the source quaternion
  2704. * @returns a new quaternion as the inverted current quaternion
  2705. */
  2706. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2707. /**
  2708. * Inverse a given quaternion
  2709. * @param q defines the source quaternion
  2710. * @param result the quaternion the result will be stored in
  2711. * @returns the result quaternion
  2712. */
  2713. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2714. /**
  2715. * Creates an identity quaternion
  2716. * @returns the identity quaternion
  2717. */
  2718. static Identity(): Quaternion;
  2719. /**
  2720. * Gets a boolean indicating if the given quaternion is identity
  2721. * @param quaternion defines the quaternion to check
  2722. * @returns true if the quaternion is identity
  2723. */
  2724. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2725. /**
  2726. * Creates a quaternion from a rotation around an axis
  2727. * @param axis defines the axis to use
  2728. * @param angle defines the angle to use
  2729. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2730. */
  2731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2732. /**
  2733. * Creates a rotation around an axis and stores it into the given quaternion
  2734. * @param axis defines the axis to use
  2735. * @param angle defines the angle to use
  2736. * @param result defines the target quaternion
  2737. * @returns the target quaternion
  2738. */
  2739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2740. /**
  2741. * Creates a new quaternion from data stored into an array
  2742. * @param array defines the data source
  2743. * @param offset defines the offset in the source array where the data starts
  2744. * @returns a new quaternion
  2745. */
  2746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2747. /**
  2748. * Create a quaternion from Euler rotation angles
  2749. * @param x Pitch
  2750. * @param y Yaw
  2751. * @param z Roll
  2752. * @returns the new Quaternion
  2753. */
  2754. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2755. /**
  2756. * Updates a quaternion from Euler rotation angles
  2757. * @param x Pitch
  2758. * @param y Yaw
  2759. * @param z Roll
  2760. * @param result the quaternion to store the result
  2761. * @returns the updated quaternion
  2762. */
  2763. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2764. /**
  2765. * Create a quaternion from Euler rotation vector
  2766. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2767. * @returns the new Quaternion
  2768. */
  2769. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2770. /**
  2771. * Updates a quaternion from Euler rotation vector
  2772. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2773. * @param result the quaternion to store the result
  2774. * @returns the updated quaternion
  2775. */
  2776. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2777. /**
  2778. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2779. * @param yaw defines the rotation around Y axis
  2780. * @param pitch defines the rotation around X axis
  2781. * @param roll defines the rotation around Z axis
  2782. * @returns the new quaternion
  2783. */
  2784. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2785. /**
  2786. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2787. * @param yaw defines the rotation around Y axis
  2788. * @param pitch defines the rotation around X axis
  2789. * @param roll defines the rotation around Z axis
  2790. * @param result defines the target quaternion
  2791. */
  2792. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2793. /**
  2794. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2795. * @param alpha defines the rotation around first axis
  2796. * @param beta defines the rotation around second axis
  2797. * @param gamma defines the rotation around third axis
  2798. * @returns the new quaternion
  2799. */
  2800. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2801. /**
  2802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2803. * @param alpha defines the rotation around first axis
  2804. * @param beta defines the rotation around second axis
  2805. * @param gamma defines the rotation around third axis
  2806. * @param result defines the target quaternion
  2807. */
  2808. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2809. /**
  2810. * 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)
  2811. * @param axis1 defines the first axis
  2812. * @param axis2 defines the second axis
  2813. * @param axis3 defines the third axis
  2814. * @returns the new quaternion
  2815. */
  2816. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2817. /**
  2818. * 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
  2819. * @param axis1 defines the first axis
  2820. * @param axis2 defines the second axis
  2821. * @param axis3 defines the third axis
  2822. * @param ref defines the target quaternion
  2823. */
  2824. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2825. /**
  2826. * Interpolates between two quaternions
  2827. * @param left defines first quaternion
  2828. * @param right defines second quaternion
  2829. * @param amount defines the gradient to use
  2830. * @returns the new interpolated quaternion
  2831. */
  2832. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2833. /**
  2834. * Interpolates between two quaternions and stores it into a target quaternion
  2835. * @param left defines first quaternion
  2836. * @param right defines second quaternion
  2837. * @param amount defines the gradient to use
  2838. * @param result defines the target quaternion
  2839. */
  2840. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2841. /**
  2842. * Interpolate between two quaternions using Hermite interpolation
  2843. * @param value1 defines first quaternion
  2844. * @param tangent1 defines the incoming tangent
  2845. * @param value2 defines second quaternion
  2846. * @param tangent2 defines the outgoing tangent
  2847. * @param amount defines the target quaternion
  2848. * @returns the new interpolated quaternion
  2849. */
  2850. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2851. }
  2852. /**
  2853. * Class used to store matrix data (4x4)
  2854. */
  2855. export class Matrix {
  2856. private static _updateFlagSeed;
  2857. private static _identityReadOnly;
  2858. private _isIdentity;
  2859. private _isIdentityDirty;
  2860. private _isIdentity3x2;
  2861. private _isIdentity3x2Dirty;
  2862. /**
  2863. * Gets the update flag of the matrix which is an unique number for the matrix.
  2864. * It will be incremented every time the matrix data change.
  2865. * You can use it to speed the comparison between two versions of the same matrix.
  2866. */
  2867. updateFlag: number;
  2868. private readonly _m;
  2869. /**
  2870. * Gets the internal data of the matrix
  2871. */
  2872. readonly m: DeepImmutable<Float32Array>;
  2873. /** @hidden */ private _markAsUpdated(): void;
  2874. /** @hidden */
  2875. private _updateIdentityStatus;
  2876. /**
  2877. * Creates an empty matrix (filled with zeros)
  2878. */
  2879. constructor();
  2880. /**
  2881. * Check if the current matrix is identity
  2882. * @returns true is the matrix is the identity matrix
  2883. */
  2884. isIdentity(): boolean;
  2885. /**
  2886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2887. * @returns true is the matrix is the identity matrix
  2888. */
  2889. isIdentityAs3x2(): boolean;
  2890. /**
  2891. * Gets the determinant of the matrix
  2892. * @returns the matrix determinant
  2893. */
  2894. determinant(): number;
  2895. /**
  2896. * Returns the matrix as a Float32Array
  2897. * @returns the matrix underlying array
  2898. */
  2899. toArray(): DeepImmutable<Float32Array>;
  2900. /**
  2901. * Returns the matrix as a Float32Array
  2902. * @returns the matrix underlying array.
  2903. */
  2904. asArray(): DeepImmutable<Float32Array>;
  2905. /**
  2906. * Inverts the current matrix in place
  2907. * @returns the current inverted matrix
  2908. */
  2909. invert(): Matrix;
  2910. /**
  2911. * Sets all the matrix elements to zero
  2912. * @returns the current matrix
  2913. */
  2914. reset(): Matrix;
  2915. /**
  2916. * Adds the current matrix with a second one
  2917. * @param other defines the matrix to add
  2918. * @returns a new matrix as the addition of the current matrix and the given one
  2919. */
  2920. add(other: DeepImmutable<Matrix>): Matrix;
  2921. /**
  2922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2923. * @param other defines the matrix to add
  2924. * @param result defines the target matrix
  2925. * @returns the current matrix
  2926. */
  2927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2928. /**
  2929. * Adds in place the given matrix to the current matrix
  2930. * @param other defines the second operand
  2931. * @returns the current updated matrix
  2932. */
  2933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2934. /**
  2935. * Sets the given matrix to the current inverted Matrix
  2936. * @param other defines the target matrix
  2937. * @returns the unmodified current matrix
  2938. */
  2939. invertToRef(other: Matrix): Matrix;
  2940. /**
  2941. * add a value at the specified position in the current Matrix
  2942. * @param index the index of the value within the matrix. between 0 and 15.
  2943. * @param value the value to be added
  2944. * @returns the current updated matrix
  2945. */
  2946. addAtIndex(index: number, value: number): Matrix;
  2947. /**
  2948. * mutiply the specified position in the current Matrix by a value
  2949. * @param index the index of the value within the matrix. between 0 and 15.
  2950. * @param value the value to be added
  2951. * @returns the current updated matrix
  2952. */
  2953. multiplyAtIndex(index: number, value: number): Matrix;
  2954. /**
  2955. * Inserts the translation vector (using 3 floats) in the current matrix
  2956. * @param x defines the 1st component of the translation
  2957. * @param y defines the 2nd component of the translation
  2958. * @param z defines the 3rd component of the translation
  2959. * @returns the current updated matrix
  2960. */
  2961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2962. /**
  2963. * Adds the translation vector (using 3 floats) in the current matrix
  2964. * @param x defines the 1st component of the translation
  2965. * @param y defines the 2nd component of the translation
  2966. * @param z defines the 3rd component of the translation
  2967. * @returns the current updated matrix
  2968. */
  2969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2970. /**
  2971. * Inserts the translation vector in the current matrix
  2972. * @param vector3 defines the translation to insert
  2973. * @returns the current updated matrix
  2974. */
  2975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2976. /**
  2977. * Gets the translation value of the current matrix
  2978. * @returns a new Vector3 as the extracted translation from the matrix
  2979. */
  2980. getTranslation(): Vector3;
  2981. /**
  2982. * Fill a Vector3 with the extracted translation from the matrix
  2983. * @param result defines the Vector3 where to store the translation
  2984. * @returns the current matrix
  2985. */
  2986. getTranslationToRef(result: Vector3): Matrix;
  2987. /**
  2988. * Remove rotation and scaling part from the matrix
  2989. * @returns the updated matrix
  2990. */
  2991. removeRotationAndScaling(): Matrix;
  2992. /**
  2993. * Multiply two matrices
  2994. * @param other defines the second operand
  2995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2996. */
  2997. multiply(other: DeepImmutable<Matrix>): Matrix;
  2998. /**
  2999. * Copy the current matrix from the given one
  3000. * @param other defines the source matrix
  3001. * @returns the current updated matrix
  3002. */
  3003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3004. /**
  3005. * Populates the given array from the starting index with the current matrix values
  3006. * @param array defines the target array
  3007. * @param offset defines the offset in the target array where to start storing values
  3008. * @returns the current matrix
  3009. */
  3010. copyToArray(array: Float32Array, offset?: number): Matrix;
  3011. /**
  3012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3013. * @param other defines the second operand
  3014. * @param result defines the matrix where to store the multiplication
  3015. * @returns the current matrix
  3016. */
  3017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3018. /**
  3019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3020. * @param other defines the second operand
  3021. * @param result defines the array where to store the multiplication
  3022. * @param offset defines the offset in the target array where to start storing values
  3023. * @returns the current matrix
  3024. */
  3025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3026. /**
  3027. * Check equality between this matrix and a second one
  3028. * @param value defines the second matrix to compare
  3029. * @returns true is the current matrix and the given one values are strictly equal
  3030. */
  3031. equals(value: DeepImmutable<Matrix>): boolean;
  3032. /**
  3033. * Clone the current matrix
  3034. * @returns a new matrix from the current matrix
  3035. */
  3036. clone(): Matrix;
  3037. /**
  3038. * Returns the name of the current matrix class
  3039. * @returns the string "Matrix"
  3040. */
  3041. getClassName(): string;
  3042. /**
  3043. * Gets the hash code of the current matrix
  3044. * @returns the hash code
  3045. */
  3046. getHashCode(): number;
  3047. /**
  3048. * Decomposes the current Matrix into a translation, rotation and scaling components
  3049. * @param scale defines the scale vector3 given as a reference to update
  3050. * @param rotation defines the rotation quaternion given as a reference to update
  3051. * @param translation defines the translation vector3 given as a reference to update
  3052. * @returns true if operation was successful
  3053. */
  3054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3055. /**
  3056. * Gets specific row of the matrix
  3057. * @param index defines the number of the row to get
  3058. * @returns the index-th row of the current matrix as a new Vector4
  3059. */
  3060. getRow(index: number): Nullable<Vector4>;
  3061. /**
  3062. * Sets the index-th row of the current matrix to the vector4 values
  3063. * @param index defines the number of the row to set
  3064. * @param row defines the target vector4
  3065. * @returns the updated current matrix
  3066. */
  3067. setRow(index: number, row: Vector4): Matrix;
  3068. /**
  3069. * Compute the transpose of the matrix
  3070. * @returns the new transposed matrix
  3071. */
  3072. transpose(): Matrix;
  3073. /**
  3074. * Compute the transpose of the matrix and store it in a given matrix
  3075. * @param result defines the target matrix
  3076. * @returns the current matrix
  3077. */
  3078. transposeToRef(result: Matrix): Matrix;
  3079. /**
  3080. * Sets the index-th row of the current matrix with the given 4 x float values
  3081. * @param index defines the row index
  3082. * @param x defines the x component to set
  3083. * @param y defines the y component to set
  3084. * @param z defines the z component to set
  3085. * @param w defines the w component to set
  3086. * @returns the updated current matrix
  3087. */
  3088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3089. /**
  3090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3091. * @param scale defines the scale factor
  3092. * @returns a new matrix
  3093. */
  3094. scale(scale: number): Matrix;
  3095. /**
  3096. * Scale the current matrix values by a factor to a given result matrix
  3097. * @param scale defines the scale factor
  3098. * @param result defines the matrix to store the result
  3099. * @returns the current matrix
  3100. */
  3101. scaleToRef(scale: number, result: Matrix): Matrix;
  3102. /**
  3103. * Scale the current matrix values by a factor and add the result to a given matrix
  3104. * @param scale defines the scale factor
  3105. * @param result defines the Matrix to store the result
  3106. * @returns the current matrix
  3107. */
  3108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3109. /**
  3110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3111. * @param ref matrix to store the result
  3112. */
  3113. toNormalMatrix(ref: Matrix): void;
  3114. /**
  3115. * Gets only rotation part of the current matrix
  3116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3117. */
  3118. getRotationMatrix(): Matrix;
  3119. /**
  3120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3121. * @param result defines the target matrix to store data to
  3122. * @returns the current matrix
  3123. */
  3124. getRotationMatrixToRef(result: Matrix): Matrix;
  3125. /**
  3126. * Toggles model matrix from being right handed to left handed in place and vice versa
  3127. */
  3128. toggleModelMatrixHandInPlace(): void;
  3129. /**
  3130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleProjectionMatrixHandInPlace(): void;
  3133. /**
  3134. * Creates a matrix from an array
  3135. * @param array defines the source array
  3136. * @param offset defines an offset in the source array
  3137. * @returns a new Matrix set from the starting index of the given array
  3138. */
  3139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3140. /**
  3141. * Copy the content of an array into a given matrix
  3142. * @param array defines the source array
  3143. * @param offset defines an offset in the source array
  3144. * @param result defines the target matrix
  3145. */
  3146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3147. /**
  3148. * Stores an array into a matrix after having multiplied each component by a given factor
  3149. * @param array defines the source array
  3150. * @param offset defines the offset in the source array
  3151. * @param scale defines the scaling factor
  3152. * @param result defines the target matrix
  3153. */
  3154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3155. /**
  3156. * Gets an identity matrix that must not be updated
  3157. */
  3158. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3159. /**
  3160. * Stores a list of values (16) inside a given matrix
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @param result defines the target matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates new matrix from a list of values (16)
  3182. * @param initialM11 defines 1st value of 1st row
  3183. * @param initialM12 defines 2nd value of 1st row
  3184. * @param initialM13 defines 3rd value of 1st row
  3185. * @param initialM14 defines 4th value of 1st row
  3186. * @param initialM21 defines 1st value of 2nd row
  3187. * @param initialM22 defines 2nd value of 2nd row
  3188. * @param initialM23 defines 3rd value of 2nd row
  3189. * @param initialM24 defines 4th value of 2nd row
  3190. * @param initialM31 defines 1st value of 3rd row
  3191. * @param initialM32 defines 2nd value of 3rd row
  3192. * @param initialM33 defines 3rd value of 3rd row
  3193. * @param initialM34 defines 4th value of 3rd row
  3194. * @param initialM41 defines 1st value of 4th row
  3195. * @param initialM42 defines 2nd value of 4th row
  3196. * @param initialM43 defines 3rd value of 4th row
  3197. * @param initialM44 defines 4th value of 4th row
  3198. * @returns the new matrix
  3199. */
  3200. 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;
  3201. /**
  3202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3203. * @param scale defines the scale vector3
  3204. * @param rotation defines the rotation quaternion
  3205. * @param translation defines the translation vector3
  3206. * @returns a new matrix
  3207. */
  3208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3209. /**
  3210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3211. * @param scale defines the scale vector3
  3212. * @param rotation defines the rotation quaternion
  3213. * @param translation defines the translation vector3
  3214. * @param result defines the target matrix
  3215. */
  3216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3217. /**
  3218. * Creates a new identity matrix
  3219. * @returns a new identity matrix
  3220. */
  3221. static Identity(): Matrix;
  3222. /**
  3223. * Creates a new identity matrix and stores the result in a given matrix
  3224. * @param result defines the target matrix
  3225. */
  3226. static IdentityToRef(result: Matrix): void;
  3227. /**
  3228. * Creates a new zero matrix
  3229. * @returns a new zero matrix
  3230. */
  3231. static Zero(): Matrix;
  3232. /**
  3233. * Creates a new rotation matrix for "angle" radians around the X axis
  3234. * @param angle defines the angle (in radians) to use
  3235. * @return the new matrix
  3236. */
  3237. static RotationX(angle: number): Matrix;
  3238. /**
  3239. * Creates a new matrix as the invert of a given matrix
  3240. * @param source defines the source matrix
  3241. * @returns the new matrix
  3242. */
  3243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3244. /**
  3245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3246. * @param angle defines the angle (in radians) to use
  3247. * @param result defines the target matrix
  3248. */
  3249. static RotationXToRef(angle: number, result: Matrix): void;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the Y axis
  3252. * @param angle defines the angle (in radians) to use
  3253. * @return the new matrix
  3254. */
  3255. static RotationY(angle: number): Matrix;
  3256. /**
  3257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3258. * @param angle defines the angle (in radians) to use
  3259. * @param result defines the target matrix
  3260. */
  3261. static RotationYToRef(angle: number, result: Matrix): void;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the Z axis
  3264. * @param angle defines the angle (in radians) to use
  3265. * @return the new matrix
  3266. */
  3267. static RotationZ(angle: number): Matrix;
  3268. /**
  3269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3270. * @param angle defines the angle (in radians) to use
  3271. * @param result defines the target matrix
  3272. */
  3273. static RotationZToRef(angle: number, result: Matrix): void;
  3274. /**
  3275. * Creates a new rotation matrix for "angle" radians around the given axis
  3276. * @param axis defines the axis to use
  3277. * @param angle defines the angle (in radians) to use
  3278. * @return the new matrix
  3279. */
  3280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3281. /**
  3282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3283. * @param axis defines the axis to use
  3284. * @param angle defines the angle (in radians) to use
  3285. * @param result defines the target matrix
  3286. */
  3287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3288. /**
  3289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3291. * @param from defines the vector to align
  3292. * @param to defines the vector to align to
  3293. * @param result defines the target matrix
  3294. */
  3295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3296. /**
  3297. * Creates a rotation matrix
  3298. * @param yaw defines the yaw angle in radians (Y axis)
  3299. * @param pitch defines the pitch angle in radians (X axis)
  3300. * @param roll defines the roll angle in radians (X axis)
  3301. * @returns the new rotation matrix
  3302. */
  3303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3304. /**
  3305. * Creates a rotation matrix and stores it in a given matrix
  3306. * @param yaw defines the yaw angle in radians (Y axis)
  3307. * @param pitch defines the pitch angle in radians (X axis)
  3308. * @param roll defines the roll angle in radians (X axis)
  3309. * @param result defines the target matrix
  3310. */
  3311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3312. /**
  3313. * Creates a scaling matrix
  3314. * @param x defines the scale factor on X axis
  3315. * @param y defines the scale factor on Y axis
  3316. * @param z defines the scale factor on Z axis
  3317. * @returns the new matrix
  3318. */
  3319. static Scaling(x: number, y: number, z: number): Matrix;
  3320. /**
  3321. * Creates a scaling matrix and stores it in a given matrix
  3322. * @param x defines the scale factor on X axis
  3323. * @param y defines the scale factor on Y axis
  3324. * @param z defines the scale factor on Z axis
  3325. * @param result defines the target matrix
  3326. */
  3327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3328. /**
  3329. * Creates a translation matrix
  3330. * @param x defines the translation on X axis
  3331. * @param y defines the translation on Y axis
  3332. * @param z defines the translationon Z axis
  3333. * @returns the new matrix
  3334. */
  3335. static Translation(x: number, y: number, z: number): Matrix;
  3336. /**
  3337. * Creates a translation matrix and stores it in a given matrix
  3338. * @param x defines the translation on X axis
  3339. * @param y defines the translation on Y axis
  3340. * @param z defines the translationon Z axis
  3341. * @param result defines the target matrix
  3342. */
  3343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3344. /**
  3345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3346. * @param startValue defines the start value
  3347. * @param endValue defines the end value
  3348. * @param gradient defines the gradient factor
  3349. * @returns the new matrix
  3350. */
  3351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3354. * @param startValue defines the start value
  3355. * @param endValue defines the end value
  3356. * @param gradient defines the gradient factor
  3357. * @param result defines the Matrix object where to store data
  3358. */
  3359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3360. /**
  3361. * Builds a new matrix whose values are computed by:
  3362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3365. * @param startValue defines the first matrix
  3366. * @param endValue defines the second matrix
  3367. * @param gradient defines the gradient between the two matrices
  3368. * @returns the new matrix
  3369. */
  3370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3371. /**
  3372. * Update a matrix to values which are computed by:
  3373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3376. * @param startValue defines the first matrix
  3377. * @param endValue defines the second matrix
  3378. * @param gradient defines the gradient between the two matrices
  3379. * @param result defines the target matrix
  3380. */
  3381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3382. /**
  3383. * 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"
  3384. * This function works in left handed mode
  3385. * @param eye defines the final position of the entity
  3386. * @param target defines where the entity should look at
  3387. * @param up defines the up vector for the entity
  3388. * @returns the new matrix
  3389. */
  3390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3391. /**
  3392. * 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".
  3393. * This function works in left handed mode
  3394. * @param eye defines the final position of the entity
  3395. * @param target defines where the entity should look at
  3396. * @param up defines the up vector for the entity
  3397. * @param result defines the target matrix
  3398. */
  3399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3400. /**
  3401. * 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"
  3402. * This function works in right handed mode
  3403. * @param eye defines the final position of the entity
  3404. * @param target defines where the entity should look at
  3405. * @param up defines the up vector for the entity
  3406. * @returns the new matrix
  3407. */
  3408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3409. /**
  3410. * 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".
  3411. * This function works in right handed mode
  3412. * @param eye defines the final position of the entity
  3413. * @param target defines where the entity should look at
  3414. * @param up defines the up vector for the entity
  3415. * @param result defines the target matrix
  3416. */
  3417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3418. /**
  3419. * Create a left-handed orthographic projection matrix
  3420. * @param width defines the viewport width
  3421. * @param height defines the viewport height
  3422. * @param znear defines the near clip plane
  3423. * @param zfar defines the far clip plane
  3424. * @returns a new matrix as a left-handed orthographic projection matrix
  3425. */
  3426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3427. /**
  3428. * Store a left-handed orthographic projection to a given matrix
  3429. * @param width defines the viewport width
  3430. * @param height defines the viewport height
  3431. * @param znear defines the near clip plane
  3432. * @param zfar defines the far clip plane
  3433. * @param result defines the target matrix
  3434. */
  3435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3436. /**
  3437. * Create a left-handed orthographic projection matrix
  3438. * @param left defines the viewport left coordinate
  3439. * @param right defines the viewport right coordinate
  3440. * @param bottom defines the viewport bottom coordinate
  3441. * @param top defines the viewport top coordinate
  3442. * @param znear defines the near clip plane
  3443. * @param zfar defines the far clip plane
  3444. * @returns a new matrix as a left-handed orthographic projection matrix
  3445. */
  3446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3447. /**
  3448. * Stores a left-handed orthographic projection into a given matrix
  3449. * @param left defines the viewport left coordinate
  3450. * @param right defines the viewport right coordinate
  3451. * @param bottom defines the viewport bottom coordinate
  3452. * @param top defines the viewport top coordinate
  3453. * @param znear defines the near clip plane
  3454. * @param zfar defines the far clip plane
  3455. * @param result defines the target matrix
  3456. */
  3457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3458. /**
  3459. * Creates a right-handed orthographic projection matrix
  3460. * @param left defines the viewport left coordinate
  3461. * @param right defines the viewport right coordinate
  3462. * @param bottom defines the viewport bottom coordinate
  3463. * @param top defines the viewport top coordinate
  3464. * @param znear defines the near clip plane
  3465. * @param zfar defines the far clip plane
  3466. * @returns a new matrix as a right-handed orthographic projection matrix
  3467. */
  3468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3469. /**
  3470. * Stores a right-handed orthographic projection into a given matrix
  3471. * @param left defines the viewport left coordinate
  3472. * @param right defines the viewport right coordinate
  3473. * @param bottom defines the viewport bottom coordinate
  3474. * @param top defines the viewport top coordinate
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @param result defines the target matrix
  3478. */
  3479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3480. /**
  3481. * Creates a left-handed perspective projection matrix
  3482. * @param width defines the viewport width
  3483. * @param height defines the viewport height
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @returns a new matrix as a left-handed perspective projection matrix
  3487. */
  3488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3489. /**
  3490. * Creates a left-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a left-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a left-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Creates a right-handed perspective projection matrix
  3510. * @param fov defines the horizontal field of view
  3511. * @param aspect defines the aspect ratio
  3512. * @param znear defines the near clip plane
  3513. * @param zfar defines the far clip plane
  3514. * @returns a new matrix as a right-handed perspective projection matrix
  3515. */
  3516. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3517. /**
  3518. * Stores a right-handed perspective projection into a given matrix
  3519. * @param fov defines the horizontal field of view
  3520. * @param aspect defines the aspect ratio
  3521. * @param znear defines the near clip plane
  3522. * @param zfar defines the far clip plane
  3523. * @param result defines the target matrix
  3524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3525. */
  3526. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3527. /**
  3528. * Stores a perspective projection for WebVR info a given matrix
  3529. * @param fov defines the field of view
  3530. * @param znear defines the near clip plane
  3531. * @param zfar defines the far clip plane
  3532. * @param result defines the target matrix
  3533. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3534. */
  3535. static PerspectiveFovWebVRToRef(fov: {
  3536. upDegrees: number;
  3537. downDegrees: number;
  3538. leftDegrees: number;
  3539. rightDegrees: number;
  3540. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3541. /**
  3542. * Computes a complete transformation matrix
  3543. * @param viewport defines the viewport to use
  3544. * @param world defines the world matrix
  3545. * @param view defines the view matrix
  3546. * @param projection defines the projection matrix
  3547. * @param zmin defines the near clip plane
  3548. * @param zmax defines the far clip plane
  3549. * @returns the transformation matrix
  3550. */
  3551. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3552. /**
  3553. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3554. * @param matrix defines the matrix to use
  3555. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3556. */
  3557. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3558. /**
  3559. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3560. * @param matrix defines the matrix to use
  3561. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3562. */
  3563. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3564. /**
  3565. * Compute the transpose of a given matrix
  3566. * @param matrix defines the matrix to transpose
  3567. * @returns the new matrix
  3568. */
  3569. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3570. /**
  3571. * Compute the transpose of a matrix and store it in a target matrix
  3572. * @param matrix defines the matrix to transpose
  3573. * @param result defines the target matrix
  3574. */
  3575. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3576. /**
  3577. * Computes a reflection matrix from a plane
  3578. * @param plane defines the reflection plane
  3579. * @returns a new matrix
  3580. */
  3581. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3582. /**
  3583. * Computes a reflection matrix from a plane
  3584. * @param plane defines the reflection plane
  3585. * @param result defines the target matrix
  3586. */
  3587. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3588. /**
  3589. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3590. * @param xaxis defines the value of the 1st axis
  3591. * @param yaxis defines the value of the 2nd axis
  3592. * @param zaxis defines the value of the 3rd axis
  3593. * @param result defines the target matrix
  3594. */
  3595. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3596. /**
  3597. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3598. * @param quat defines the quaternion to use
  3599. * @param result defines the target matrix
  3600. */
  3601. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3602. }
  3603. /**
  3604. * Represens a plane by the equation ax + by + cz + d = 0
  3605. */
  3606. export class Plane {
  3607. /**
  3608. * Normal of the plane (a,b,c)
  3609. */
  3610. normal: Vector3;
  3611. /**
  3612. * d component of the plane
  3613. */
  3614. d: number;
  3615. /**
  3616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3617. * @param a a component of the plane
  3618. * @param b b component of the plane
  3619. * @param c c component of the plane
  3620. * @param d d component of the plane
  3621. */
  3622. constructor(a: number, b: number, c: number, d: number);
  3623. /**
  3624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3625. */
  3626. asArray(): number[];
  3627. /**
  3628. * @returns a new plane copied from the current Plane.
  3629. */
  3630. clone(): Plane;
  3631. /**
  3632. * @returns the string "Plane".
  3633. */
  3634. getClassName(): string;
  3635. /**
  3636. * @returns the Plane hash code.
  3637. */
  3638. getHashCode(): number;
  3639. /**
  3640. * Normalize the current Plane in place.
  3641. * @returns the updated Plane.
  3642. */
  3643. normalize(): Plane;
  3644. /**
  3645. * Applies a transformation the plane and returns the result
  3646. * @param transformation the transformation matrix to be applied to the plane
  3647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3648. */
  3649. transform(transformation: DeepImmutable<Matrix>): Plane;
  3650. /**
  3651. * Calcualtte the dot product between the point and the plane normal
  3652. * @param point point to calculate the dot product with
  3653. * @returns the dot product (float) of the point coordinates and the plane normal.
  3654. */
  3655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Updates the current Plane from the plane defined by the three given points.
  3658. * @param point1 one of the points used to contruct the plane
  3659. * @param point2 one of the points used to contruct the plane
  3660. * @param point3 one of the points used to contruct the plane
  3661. * @returns the updated Plane.
  3662. */
  3663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3664. /**
  3665. * Checks if the plane is facing a given direction
  3666. * @param direction the direction to check if the plane is facing
  3667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3668. * @returns True is the vector "direction" is the same side than the plane normal.
  3669. */
  3670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3671. /**
  3672. * Calculates the distance to a point
  3673. * @param point point to calculate distance to
  3674. * @returns the signed distance (float) from the given point to the Plane.
  3675. */
  3676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3677. /**
  3678. * Creates a plane from an array
  3679. * @param array the array to create a plane from
  3680. * @returns a new Plane from the given array.
  3681. */
  3682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3683. /**
  3684. * Creates a plane from three points
  3685. * @param point1 point used to create the plane
  3686. * @param point2 point used to create the plane
  3687. * @param point3 point used to create the plane
  3688. * @returns a new Plane defined by the three given points.
  3689. */
  3690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3691. /**
  3692. * Creates a plane from an origin point and a normal
  3693. * @param origin origin of the plane to be constructed
  3694. * @param normal normal of the plane to be constructed
  3695. * @returns a new Plane the normal vector to this plane at the given origin point.
  3696. * Note : the vector "normal" is updated because normalized.
  3697. */
  3698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3699. /**
  3700. * Calculates the distance from a plane and a point
  3701. * @param origin origin of the plane to be constructed
  3702. * @param normal normal of the plane to be constructed
  3703. * @param point point to calculate distance to
  3704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3705. */
  3706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3707. }
  3708. /**
  3709. * Class used to represent a viewport on screen
  3710. */
  3711. export class Viewport {
  3712. /** viewport left coordinate */
  3713. x: number;
  3714. /** viewport top coordinate */
  3715. y: number;
  3716. /**viewport width */
  3717. width: number;
  3718. /** viewport height */
  3719. height: number;
  3720. /**
  3721. * Creates a Viewport object located at (x, y) and sized (width, height)
  3722. * @param x defines viewport left coordinate
  3723. * @param y defines viewport top coordinate
  3724. * @param width defines the viewport width
  3725. * @param height defines the viewport height
  3726. */
  3727. constructor(
  3728. /** viewport left coordinate */
  3729. x: number,
  3730. /** viewport top coordinate */
  3731. y: number,
  3732. /**viewport width */
  3733. width: number,
  3734. /** viewport height */
  3735. height: number);
  3736. /**
  3737. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3738. * @param renderWidth defines the rendering width
  3739. * @param renderHeight defines the rendering height
  3740. * @returns a new Viewport
  3741. */
  3742. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3743. /**
  3744. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3745. * @param renderWidth defines the rendering width
  3746. * @param renderHeight defines the rendering height
  3747. * @param ref defines the target viewport
  3748. * @returns the current viewport
  3749. */
  3750. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3751. /**
  3752. * Returns a new Viewport copied from the current one
  3753. * @returns a new Viewport
  3754. */
  3755. clone(): Viewport;
  3756. }
  3757. /**
  3758. * Reprasents a camera frustum
  3759. */
  3760. export class Frustum {
  3761. /**
  3762. * Gets the planes representing the frustum
  3763. * @param transform matrix to be applied to the returned planes
  3764. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3765. */
  3766. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3767. /**
  3768. * Gets the near frustum plane transformed by the transform matrix
  3769. * @param transform transformation matrix to be applied to the resulting frustum plane
  3770. * @param frustumPlane the resuling frustum plane
  3771. */
  3772. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3773. /**
  3774. * Gets the far frustum plane transformed by the transform matrix
  3775. * @param transform transformation matrix to be applied to the resulting frustum plane
  3776. * @param frustumPlane the resuling frustum plane
  3777. */
  3778. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3779. /**
  3780. * Gets the left frustum plane transformed by the transform matrix
  3781. * @param transform transformation matrix to be applied to the resulting frustum plane
  3782. * @param frustumPlane the resuling frustum plane
  3783. */
  3784. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3785. /**
  3786. * Gets the right frustum plane transformed by the transform matrix
  3787. * @param transform transformation matrix to be applied to the resulting frustum plane
  3788. * @param frustumPlane the resuling frustum plane
  3789. */
  3790. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3791. /**
  3792. * Gets the top frustum plane transformed by the transform matrix
  3793. * @param transform transformation matrix to be applied to the resulting frustum plane
  3794. * @param frustumPlane the resuling frustum plane
  3795. */
  3796. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3797. /**
  3798. * Gets the bottom frustum plane transformed by the transform matrix
  3799. * @param transform transformation matrix to be applied to the resulting frustum plane
  3800. * @param frustumPlane the resuling frustum plane
  3801. */
  3802. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3803. /**
  3804. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3805. * @param transform transformation matrix to be applied to the resulting frustum planes
  3806. * @param frustumPlanes the resuling frustum planes
  3807. */
  3808. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3809. }
  3810. /** Defines supported spaces */
  3811. export enum Space {
  3812. /** Local (object) space */
  3813. LOCAL = 0,
  3814. /** World space */
  3815. WORLD = 1,
  3816. /** Bone space */
  3817. BONE = 2
  3818. }
  3819. /** Defines the 3 main axes */
  3820. export class Axis {
  3821. /** X axis */
  3822. static X: Vector3;
  3823. /** Y axis */
  3824. static Y: Vector3;
  3825. /** Z axis */
  3826. static Z: Vector3;
  3827. }
  3828. /** Class used to represent a Bezier curve */
  3829. export class BezierCurve {
  3830. /**
  3831. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3832. * @param t defines the time
  3833. * @param x1 defines the left coordinate on X axis
  3834. * @param y1 defines the left coordinate on Y axis
  3835. * @param x2 defines the right coordinate on X axis
  3836. * @param y2 defines the right coordinate on Y axis
  3837. * @returns the interpolated value
  3838. */
  3839. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3840. }
  3841. /**
  3842. * Defines potential orientation for back face culling
  3843. */
  3844. export enum Orientation {
  3845. /**
  3846. * Clockwise
  3847. */
  3848. CW = 0,
  3849. /** Counter clockwise */
  3850. CCW = 1
  3851. }
  3852. /**
  3853. * Defines angle representation
  3854. */
  3855. export class Angle {
  3856. private _radians;
  3857. /**
  3858. * Creates an Angle object of "radians" radians (float).
  3859. * @param radians the angle in radians
  3860. */
  3861. constructor(radians: number);
  3862. /**
  3863. * Get value in degrees
  3864. * @returns the Angle value in degrees (float)
  3865. */
  3866. degrees(): number;
  3867. /**
  3868. * Get value in radians
  3869. * @returns the Angle value in radians (float)
  3870. */
  3871. radians(): number;
  3872. /**
  3873. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3874. * @param a defines first vector
  3875. * @param b defines second vector
  3876. * @returns a new Angle
  3877. */
  3878. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3879. /**
  3880. * Gets a new Angle object from the given float in radians
  3881. * @param radians defines the angle value in radians
  3882. * @returns a new Angle
  3883. */
  3884. static FromRadians(radians: number): Angle;
  3885. /**
  3886. * Gets a new Angle object from the given float in degrees
  3887. * @param degrees defines the angle value in degrees
  3888. * @returns a new Angle
  3889. */
  3890. static FromDegrees(degrees: number): Angle;
  3891. }
  3892. /**
  3893. * This represents an arc in a 2d space.
  3894. */
  3895. export class Arc2 {
  3896. /** Defines the start point of the arc */
  3897. startPoint: Vector2;
  3898. /** Defines the mid point of the arc */
  3899. midPoint: Vector2;
  3900. /** Defines the end point of the arc */
  3901. endPoint: Vector2;
  3902. /**
  3903. * Defines the center point of the arc.
  3904. */
  3905. centerPoint: Vector2;
  3906. /**
  3907. * Defines the radius of the arc.
  3908. */
  3909. radius: number;
  3910. /**
  3911. * Defines the angle of the arc (from mid point to end point).
  3912. */
  3913. angle: Angle;
  3914. /**
  3915. * Defines the start angle of the arc (from start point to middle point).
  3916. */
  3917. startAngle: Angle;
  3918. /**
  3919. * Defines the orientation of the arc (clock wise/counter clock wise).
  3920. */
  3921. orientation: Orientation;
  3922. /**
  3923. * Creates an Arc object from the three given points : start, middle and end.
  3924. * @param startPoint Defines the start point of the arc
  3925. * @param midPoint Defines the midlle point of the arc
  3926. * @param endPoint Defines the end point of the arc
  3927. */
  3928. constructor(
  3929. /** Defines the start point of the arc */
  3930. startPoint: Vector2,
  3931. /** Defines the mid point of the arc */
  3932. midPoint: Vector2,
  3933. /** Defines the end point of the arc */
  3934. endPoint: Vector2);
  3935. }
  3936. /**
  3937. * Represents a 2D path made up of multiple 2D points
  3938. */
  3939. export class Path2 {
  3940. private _points;
  3941. private _length;
  3942. /**
  3943. * If the path start and end point are the same
  3944. */
  3945. closed: boolean;
  3946. /**
  3947. * Creates a Path2 object from the starting 2D coordinates x and y.
  3948. * @param x the starting points x value
  3949. * @param y the starting points y value
  3950. */
  3951. constructor(x: number, y: number);
  3952. /**
  3953. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3954. * @param x the added points x value
  3955. * @param y the added points y value
  3956. * @returns the updated Path2.
  3957. */
  3958. addLineTo(x: number, y: number): Path2;
  3959. /**
  3960. * 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.
  3961. * @param midX middle point x value
  3962. * @param midY middle point y value
  3963. * @param endX end point x value
  3964. * @param endY end point y value
  3965. * @param numberOfSegments (default: 36)
  3966. * @returns the updated Path2.
  3967. */
  3968. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3969. /**
  3970. * Closes the Path2.
  3971. * @returns the Path2.
  3972. */
  3973. close(): Path2;
  3974. /**
  3975. * Gets the sum of the distance between each sequential point in the path
  3976. * @returns the Path2 total length (float).
  3977. */
  3978. length(): number;
  3979. /**
  3980. * Gets the points which construct the path
  3981. * @returns the Path2 internal array of points.
  3982. */
  3983. getPoints(): Vector2[];
  3984. /**
  3985. * Retreives the point at the distance aways from the starting point
  3986. * @param normalizedLengthPosition the length along the path to retreive the point from
  3987. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3988. */
  3989. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3990. /**
  3991. * Creates a new path starting from an x and y position
  3992. * @param x starting x value
  3993. * @param y starting y value
  3994. * @returns a new Path2 starting at the coordinates (x, y).
  3995. */
  3996. static StartingAt(x: number, y: number): Path2;
  3997. }
  3998. /**
  3999. * Represents a 3D path made up of multiple 3D points
  4000. */
  4001. export class Path3D {
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[];
  4006. private _curve;
  4007. private _distances;
  4008. private _tangents;
  4009. private _normals;
  4010. private _binormals;
  4011. private _raw;
  4012. /**
  4013. * new Path3D(path, normal, raw)
  4014. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4015. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4016. * @param path an array of Vector3, the curve axis of the Path3D
  4017. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4018. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4019. */
  4020. constructor(
  4021. /**
  4022. * an array of Vector3, the curve axis of the Path3D
  4023. */
  4024. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4025. /**
  4026. * Returns the Path3D array of successive Vector3 designing its curve.
  4027. * @returns the Path3D array of successive Vector3 designing its curve.
  4028. */
  4029. getCurve(): Vector3[];
  4030. /**
  4031. * Returns an array populated with tangent vectors on each Path3D curve point.
  4032. * @returns an array populated with tangent vectors on each Path3D curve point.
  4033. */
  4034. getTangents(): Vector3[];
  4035. /**
  4036. * Returns an array populated with normal vectors on each Path3D curve point.
  4037. * @returns an array populated with normal vectors on each Path3D curve point.
  4038. */
  4039. getNormals(): Vector3[];
  4040. /**
  4041. * Returns an array populated with binormal vectors on each Path3D curve point.
  4042. * @returns an array populated with binormal vectors on each Path3D curve point.
  4043. */
  4044. getBinormals(): Vector3[];
  4045. /**
  4046. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4047. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4048. */
  4049. getDistances(): number[];
  4050. /**
  4051. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4052. * @param path path which all values are copied into the curves points
  4053. * @param firstNormal which should be projected onto the curve
  4054. * @returns the same object updated.
  4055. */
  4056. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4057. private _compute;
  4058. private _getFirstNonNullVector;
  4059. private _getLastNonNullVector;
  4060. private _normalVector;
  4061. }
  4062. /**
  4063. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4064. * A Curve3 is designed from a series of successive Vector3.
  4065. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4066. */
  4067. export class Curve3 {
  4068. private _points;
  4069. private _length;
  4070. /**
  4071. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4072. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4073. * @param v1 (Vector3) the control point
  4074. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4075. * @param nbPoints (integer) the wanted number of points in the curve
  4076. * @returns the created Curve3
  4077. */
  4078. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4079. /**
  4080. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4081. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4082. * @param v1 (Vector3) the first control point
  4083. * @param v2 (Vector3) the second control point
  4084. * @param v3 (Vector3) the end point of the Cubic Bezier
  4085. * @param nbPoints (integer) the wanted number of points in the curve
  4086. * @returns the created Curve3
  4087. */
  4088. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4089. /**
  4090. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4091. * @param p1 (Vector3) the origin point of the Hermite Spline
  4092. * @param t1 (Vector3) the tangent vector at the origin point
  4093. * @param p2 (Vector3) the end point of the Hermite Spline
  4094. * @param t2 (Vector3) the tangent vector at the end point
  4095. * @param nbPoints (integer) the wanted number of points in the curve
  4096. * @returns the created Curve3
  4097. */
  4098. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4099. /**
  4100. * Returns a Curve3 object along a CatmullRom Spline curve :
  4101. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4102. * @param nbPoints (integer) the wanted number of points between each curve control points
  4103. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4104. * @returns the created Curve3
  4105. */
  4106. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4107. /**
  4108. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4109. * A Curve3 is designed from a series of successive Vector3.
  4110. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4111. * @param points points which make up the curve
  4112. */
  4113. constructor(points: Vector3[]);
  4114. /**
  4115. * @returns the Curve3 stored array of successive Vector3
  4116. */
  4117. getPoints(): Vector3[];
  4118. /**
  4119. * @returns the computed length (float) of the curve.
  4120. */
  4121. length(): number;
  4122. /**
  4123. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4124. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4125. * curveA and curveB keep unchanged.
  4126. * @param curve the curve to continue from this curve
  4127. * @returns the newly constructed curve
  4128. */
  4129. continue(curve: DeepImmutable<Curve3>): Curve3;
  4130. private _computeLength;
  4131. }
  4132. /**
  4133. * Contains position and normal vectors for a vertex
  4134. */
  4135. export class PositionNormalVertex {
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position: Vector3;
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal: Vector3;
  4140. /**
  4141. * Creates a PositionNormalVertex
  4142. * @param position the position of the vertex (defaut: 0,0,0)
  4143. * @param normal the normal of the vertex (defaut: 0,1,0)
  4144. */
  4145. constructor(
  4146. /** the position of the vertex (defaut: 0,0,0) */
  4147. position?: Vector3,
  4148. /** the normal of the vertex (defaut: 0,1,0) */
  4149. normal?: Vector3);
  4150. /**
  4151. * Clones the PositionNormalVertex
  4152. * @returns the cloned PositionNormalVertex
  4153. */
  4154. clone(): PositionNormalVertex;
  4155. }
  4156. /**
  4157. * Contains position, normal and uv vectors for a vertex
  4158. */
  4159. export class PositionNormalTextureVertex {
  4160. /** the position of the vertex (defaut: 0,0,0) */
  4161. position: Vector3;
  4162. /** the normal of the vertex (defaut: 0,1,0) */
  4163. normal: Vector3;
  4164. /** the uv of the vertex (default: 0,0) */
  4165. uv: Vector2;
  4166. /**
  4167. * Creates a PositionNormalTextureVertex
  4168. * @param position the position of the vertex (defaut: 0,0,0)
  4169. * @param normal the normal of the vertex (defaut: 0,1,0)
  4170. * @param uv the uv of the vertex (default: 0,0)
  4171. */
  4172. constructor(
  4173. /** the position of the vertex (defaut: 0,0,0) */
  4174. position?: Vector3,
  4175. /** the normal of the vertex (defaut: 0,1,0) */
  4176. normal?: Vector3,
  4177. /** the uv of the vertex (default: 0,0) */
  4178. uv?: Vector2);
  4179. /**
  4180. * Clones the PositionNormalTextureVertex
  4181. * @returns the cloned PositionNormalTextureVertex
  4182. */
  4183. clone(): PositionNormalTextureVertex;
  4184. }
  4185. /**
  4186. * @hidden
  4187. */
  4188. export class Tmp {
  4189. static Color3: Color3[];
  4190. static Color4: Color4[];
  4191. static Vector2: Vector2[];
  4192. static Vector3: Vector3[];
  4193. static Vector4: Vector4[];
  4194. static Quaternion: Quaternion[];
  4195. static Matrix: Matrix[];
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * Class used to enable access to offline support
  4201. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4202. */
  4203. export interface IOfflineProvider {
  4204. /**
  4205. * Gets a boolean indicating if scene must be saved in the database
  4206. */
  4207. enableSceneOffline: boolean;
  4208. /**
  4209. * Gets a boolean indicating if textures must be saved in the database
  4210. */
  4211. enableTexturesOffline: boolean;
  4212. /**
  4213. * Open the offline support and make it available
  4214. * @param successCallback defines the callback to call on success
  4215. * @param errorCallback defines the callback to call on error
  4216. */
  4217. open(successCallback: () => void, errorCallback: () => void): void;
  4218. /**
  4219. * Loads an image from the offline support
  4220. * @param url defines the url to load from
  4221. * @param image defines the target DOM image
  4222. */
  4223. loadImage(url: string, image: HTMLImageElement): void;
  4224. /**
  4225. * Loads a file from offline support
  4226. * @param url defines the URL to load from
  4227. * @param sceneLoaded defines a callback to call on success
  4228. * @param progressCallBack defines a callback to call when progress changed
  4229. * @param errorCallback defines a callback to call on error
  4230. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4231. */
  4232. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4233. }
  4234. }
  4235. declare module BABYLON {
  4236. /**
  4237. * A class serves as a medium between the observable and its observers
  4238. */
  4239. export class EventState {
  4240. /**
  4241. * Create a new EventState
  4242. * @param mask defines the mask associated with this state
  4243. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4244. * @param target defines the original target of the state
  4245. * @param currentTarget defines the current target of the state
  4246. */
  4247. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4248. /**
  4249. * Initialize the current event state
  4250. * @param mask defines the mask associated with this state
  4251. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4252. * @param target defines the original target of the state
  4253. * @param currentTarget defines the current target of the state
  4254. * @returns the current event state
  4255. */
  4256. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4257. /**
  4258. * An Observer can set this property to true to prevent subsequent observers of being notified
  4259. */
  4260. skipNextObservers: boolean;
  4261. /**
  4262. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4263. */
  4264. mask: number;
  4265. /**
  4266. * The object that originally notified the event
  4267. */
  4268. target?: any;
  4269. /**
  4270. * The current object in the bubbling phase
  4271. */
  4272. currentTarget?: any;
  4273. /**
  4274. * This will be populated with the return value of the last function that was executed.
  4275. * If it is the first function in the callback chain it will be the event data.
  4276. */
  4277. lastReturnValue?: any;
  4278. }
  4279. /**
  4280. * Represent an Observer registered to a given Observable object.
  4281. */
  4282. export class Observer<T> {
  4283. /**
  4284. * Defines the callback to call when the observer is notified
  4285. */
  4286. callback: (eventData: T, eventState: EventState) => void;
  4287. /**
  4288. * Defines the mask of the observer (used to filter notifications)
  4289. */
  4290. mask: number;
  4291. /**
  4292. * Defines the current scope used to restore the JS context
  4293. */
  4294. scope: any;
  4295. /** @hidden */ private _willBeUnregistered: boolean;
  4296. /**
  4297. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4298. */
  4299. unregisterOnNextCall: boolean;
  4300. /**
  4301. * Creates a new observer
  4302. * @param callback defines the callback to call when the observer is notified
  4303. * @param mask defines the mask of the observer (used to filter notifications)
  4304. * @param scope defines the current scope used to restore the JS context
  4305. */
  4306. constructor(
  4307. /**
  4308. * Defines the callback to call when the observer is notified
  4309. */
  4310. callback: (eventData: T, eventState: EventState) => void,
  4311. /**
  4312. * Defines the mask of the observer (used to filter notifications)
  4313. */
  4314. mask: number,
  4315. /**
  4316. * Defines the current scope used to restore the JS context
  4317. */
  4318. scope?: any);
  4319. }
  4320. /**
  4321. * Represent a list of observers registered to multiple Observables object.
  4322. */
  4323. export class MultiObserver<T> {
  4324. private _observers;
  4325. private _observables;
  4326. /**
  4327. * Release associated resources
  4328. */
  4329. dispose(): void;
  4330. /**
  4331. * Raise a callback when one of the observable will notify
  4332. * @param observables defines a list of observables to watch
  4333. * @param callback defines the callback to call on notification
  4334. * @param mask defines the mask used to filter notifications
  4335. * @param scope defines the current scope used to restore the JS context
  4336. * @returns the new MultiObserver
  4337. */
  4338. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4339. }
  4340. /**
  4341. * The Observable class is a simple implementation of the Observable pattern.
  4342. *
  4343. * 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.
  4344. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4345. * 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).
  4346. * 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.
  4347. */
  4348. export class Observable<T> {
  4349. private _observers;
  4350. private _eventState;
  4351. private _onObserverAdded;
  4352. /**
  4353. * Creates a new observable
  4354. * @param onObserverAdded defines a callback to call when a new observer is added
  4355. */
  4356. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4357. /**
  4358. * Create a new Observer with the specified callback
  4359. * @param callback the callback that will be executed for that Observer
  4360. * @param mask the mask used to filter observers
  4361. * @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.
  4362. * @param scope optional scope for the callback to be called from
  4363. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4364. * @returns the new observer created for the callback
  4365. */
  4366. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4367. /**
  4368. * Create a new Observer with the specified callback and unregisters after the next notification
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @returns the new observer created for the callback
  4371. */
  4372. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4373. /**
  4374. * Remove an Observer from the Observable object
  4375. * @param observer the instance of the Observer to remove
  4376. * @returns false if it doesn't belong to this Observable
  4377. */
  4378. remove(observer: Nullable<Observer<T>>): boolean;
  4379. /**
  4380. * Remove a callback from the Observable object
  4381. * @param callback the callback to remove
  4382. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4383. * @returns false if it doesn't belong to this Observable
  4384. */
  4385. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4386. private _deferUnregister;
  4387. private _remove;
  4388. /**
  4389. * Moves the observable to the top of the observer list making it get called first when notified
  4390. * @param observer the observer to move
  4391. */
  4392. makeObserverTopPriority(observer: Observer<T>): void;
  4393. /**
  4394. * Moves the observable to the bottom of the observer list making it get called last when notified
  4395. * @param observer the observer to move
  4396. */
  4397. makeObserverBottomPriority(observer: Observer<T>): void;
  4398. /**
  4399. * Notify all Observers by calling their respective callback with the given data
  4400. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4401. * @param eventData defines the data to send to all observers
  4402. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4403. * @param target defines the original target of the state
  4404. * @param currentTarget defines the current target of the state
  4405. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4406. */
  4407. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4408. /**
  4409. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4410. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4411. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4412. * and it is crucial that all callbacks will be executed.
  4413. * The order of the callbacks is kept, callbacks are not executed parallel.
  4414. *
  4415. * @param eventData The data to be sent to each callback
  4416. * @param mask is used to filter observers defaults to -1
  4417. * @param target defines the callback target (see EventState)
  4418. * @param currentTarget defines he current object in the bubbling phase
  4419. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4420. */
  4421. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4422. /**
  4423. * Notify a specific observer
  4424. * @param observer defines the observer to notify
  4425. * @param eventData defines the data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. */
  4428. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4429. /**
  4430. * Gets a boolean indicating if the observable has at least one observer
  4431. * @returns true is the Observable has at least one Observer registered
  4432. */
  4433. hasObservers(): boolean;
  4434. /**
  4435. * Clear the list of observers
  4436. */
  4437. clear(): void;
  4438. /**
  4439. * Clone the current observable
  4440. * @returns a new observable
  4441. */
  4442. clone(): Observable<T>;
  4443. /**
  4444. * Does this observable handles observer registered with a given mask
  4445. * @param mask defines the mask to be tested
  4446. * @return whether or not one observer registered with the given mask is handeled
  4447. **/
  4448. hasSpecificMask(mask?: number): boolean;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to help managing file picking and drag'n'drop
  4454. * File Storage
  4455. */
  4456. export class FilesInputStore {
  4457. /**
  4458. * List of files ready to be loaded
  4459. */
  4460. static FilesToLoad: {
  4461. [key: string]: File;
  4462. };
  4463. }
  4464. }
  4465. declare module BABYLON {
  4466. /** Defines the cross module used constants to avoid circular dependncies */
  4467. export class Constants {
  4468. /** Defines that alpha blending is disabled */
  4469. static readonly ALPHA_DISABLE: number;
  4470. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4471. static readonly ALPHA_ADD: number;
  4472. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4473. static readonly ALPHA_COMBINE: number;
  4474. /** Defines that alpha blending to DEST - SRC * DEST */
  4475. static readonly ALPHA_SUBTRACT: number;
  4476. /** Defines that alpha blending to SRC * DEST */
  4477. static readonly ALPHA_MULTIPLY: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4479. static readonly ALPHA_MAXIMIZED: number;
  4480. /** Defines that alpha blending to SRC + DEST */
  4481. static readonly ALPHA_ONEONE: number;
  4482. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_PREMULTIPLIED: number;
  4484. /**
  4485. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4486. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4487. */
  4488. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4489. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4490. static readonly ALPHA_INTERPOLATE: number;
  4491. /**
  4492. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4493. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4494. */
  4495. static readonly ALPHA_SCREENMODE: number;
  4496. /** Defines that the ressource is not delayed*/
  4497. static readonly DELAYLOADSTATE_NONE: number;
  4498. /** Defines that the ressource was successfully delay loaded */
  4499. static readonly DELAYLOADSTATE_LOADED: number;
  4500. /** Defines that the ressource is currently delay loading */
  4501. static readonly DELAYLOADSTATE_LOADING: number;
  4502. /** Defines that the ressource is delayed and has not started loading */
  4503. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4504. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4505. static readonly NEVER: number;
  4506. /** 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 */
  4507. static readonly ALWAYS: number;
  4508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4509. static readonly LESS: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4511. static readonly EQUAL: number;
  4512. /** 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 */
  4513. static readonly LEQUAL: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4515. static readonly GREATER: number;
  4516. /** 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 */
  4517. static readonly GEQUAL: number;
  4518. /** 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 */
  4519. static readonly NOTEQUAL: number;
  4520. /** Passed to stencilOperation to specify that stencil value must be kept */
  4521. static readonly KEEP: number;
  4522. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4523. static readonly REPLACE: number;
  4524. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4525. static readonly INCR: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4527. static readonly DECR: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4529. static readonly INVERT: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4531. static readonly INCR_WRAP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4533. static readonly DECR_WRAP: number;
  4534. /** Texture is not repeating outside of 0..1 UVs */
  4535. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4536. /** Texture is repeating outside of 0..1 UVs */
  4537. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4538. /** Texture is repeating and mirrored */
  4539. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4540. /** ALPHA */
  4541. static readonly TEXTUREFORMAT_ALPHA: number;
  4542. /** LUMINANCE */
  4543. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4544. /** LUMINANCE_ALPHA */
  4545. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4546. /** RGB */
  4547. static readonly TEXTUREFORMAT_RGB: number;
  4548. /** RGBA */
  4549. static readonly TEXTUREFORMAT_RGBA: number;
  4550. /** RED */
  4551. static readonly TEXTUREFORMAT_RED: number;
  4552. /** RED (2nd reference) */
  4553. static readonly TEXTUREFORMAT_R: number;
  4554. /** RG */
  4555. static readonly TEXTUREFORMAT_RG: number;
  4556. /** RED_INTEGER */
  4557. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4558. /** RED_INTEGER (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4560. /** RG_INTEGER */
  4561. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4562. /** RGB_INTEGER */
  4563. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4564. /** RGBA_INTEGER */
  4565. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4566. /** UNSIGNED_BYTE */
  4567. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4568. /** UNSIGNED_BYTE (2nd reference) */
  4569. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4570. /** FLOAT */
  4571. static readonly TEXTURETYPE_FLOAT: number;
  4572. /** HALF_FLOAT */
  4573. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4574. /** BYTE */
  4575. static readonly TEXTURETYPE_BYTE: number;
  4576. /** SHORT */
  4577. static readonly TEXTURETYPE_SHORT: number;
  4578. /** UNSIGNED_SHORT */
  4579. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4580. /** INT */
  4581. static readonly TEXTURETYPE_INT: number;
  4582. /** UNSIGNED_INT */
  4583. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4584. /** UNSIGNED_SHORT_4_4_4_4 */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4586. /** UNSIGNED_SHORT_5_5_5_1 */
  4587. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4588. /** UNSIGNED_SHORT_5_6_5 */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4590. /** UNSIGNED_INT_2_10_10_10_REV */
  4591. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4592. /** UNSIGNED_INT_24_8 */
  4593. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4594. /** UNSIGNED_INT_10F_11F_11F_REV */
  4595. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4596. /** UNSIGNED_INT_5_9_9_9_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4598. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4599. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4600. /** nearest is mag = nearest and min = nearest and mip = linear */
  4601. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4602. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4603. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4604. /** Trilinear is mag = linear and min = linear and mip = linear */
  4605. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4612. /** mag = nearest and min = nearest and mip = nearest */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4614. /** mag = nearest and min = linear and mip = nearest */
  4615. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4616. /** mag = nearest and min = linear and mip = linear */
  4617. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = linear and mip = none */
  4619. static readonly TEXTURE_NEAREST_LINEAR: number;
  4620. /** mag = nearest and min = nearest and mip = none */
  4621. static readonly TEXTURE_NEAREST_NEAREST: number;
  4622. /** mag = linear and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4624. /** mag = linear and min = nearest and mip = linear */
  4625. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4626. /** mag = linear and min = linear and mip = none */
  4627. static readonly TEXTURE_LINEAR_LINEAR: number;
  4628. /** mag = linear and min = nearest and mip = none */
  4629. static readonly TEXTURE_LINEAR_NEAREST: number;
  4630. /** Explicit coordinates mode */
  4631. static readonly TEXTURE_EXPLICIT_MODE: number;
  4632. /** Spherical coordinates mode */
  4633. static readonly TEXTURE_SPHERICAL_MODE: number;
  4634. /** Planar coordinates mode */
  4635. static readonly TEXTURE_PLANAR_MODE: number;
  4636. /** Cubic coordinates mode */
  4637. static readonly TEXTURE_CUBIC_MODE: number;
  4638. /** Projection coordinates mode */
  4639. static readonly TEXTURE_PROJECTION_MODE: number;
  4640. /** Skybox coordinates mode */
  4641. static readonly TEXTURE_SKYBOX_MODE: number;
  4642. /** Inverse Cubic coordinates mode */
  4643. static readonly TEXTURE_INVCUBIC_MODE: number;
  4644. /** Equirectangular coordinates mode */
  4645. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4646. /** Equirectangular Fixed coordinates mode */
  4647. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4648. /** Equirectangular Fixed Mirrored coordinates mode */
  4649. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4650. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4651. static readonly SCALEMODE_FLOOR: number;
  4652. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4653. static readonly SCALEMODE_NEAREST: number;
  4654. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4655. static readonly SCALEMODE_CEILING: number;
  4656. /**
  4657. * The dirty texture flag value
  4658. */
  4659. static readonly MATERIAL_TextureDirtyFlag: number;
  4660. /**
  4661. * The dirty light flag value
  4662. */
  4663. static readonly MATERIAL_LightDirtyFlag: number;
  4664. /**
  4665. * The dirty fresnel flag value
  4666. */
  4667. static readonly MATERIAL_FresnelDirtyFlag: number;
  4668. /**
  4669. * The dirty attribute flag value
  4670. */
  4671. static readonly MATERIAL_AttributesDirtyFlag: number;
  4672. /**
  4673. * The dirty misc flag value
  4674. */
  4675. static readonly MATERIAL_MiscDirtyFlag: number;
  4676. /**
  4677. * The all dirty flag value
  4678. */
  4679. static readonly MATERIAL_AllDirtyFlag: number;
  4680. /**
  4681. * Returns the triangle fill mode
  4682. */
  4683. static readonly MATERIAL_TriangleFillMode: number;
  4684. /**
  4685. * Returns the wireframe mode
  4686. */
  4687. static readonly MATERIAL_WireFrameFillMode: number;
  4688. /**
  4689. * Returns the point fill mode
  4690. */
  4691. static readonly MATERIAL_PointFillMode: number;
  4692. /**
  4693. * Returns the point list draw mode
  4694. */
  4695. static readonly MATERIAL_PointListDrawMode: number;
  4696. /**
  4697. * Returns the line list draw mode
  4698. */
  4699. static readonly MATERIAL_LineListDrawMode: number;
  4700. /**
  4701. * Returns the line loop draw mode
  4702. */
  4703. static readonly MATERIAL_LineLoopDrawMode: number;
  4704. /**
  4705. * Returns the line strip draw mode
  4706. */
  4707. static readonly MATERIAL_LineStripDrawMode: number;
  4708. /**
  4709. * Returns the triangle strip draw mode
  4710. */
  4711. static readonly MATERIAL_TriangleStripDrawMode: number;
  4712. /**
  4713. * Returns the triangle fan draw mode
  4714. */
  4715. static readonly MATERIAL_TriangleFanDrawMode: number;
  4716. /**
  4717. * Stores the clock-wise side orientation
  4718. */
  4719. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4720. /**
  4721. * Stores the counter clock-wise side orientation
  4722. */
  4723. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4724. /**
  4725. * Nothing
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_NothingTrigger: number;
  4729. /**
  4730. * On pick
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickTrigger: number;
  4734. /**
  4735. * On left pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLeftPickTrigger: number;
  4739. /**
  4740. * On right pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnRightPickTrigger: number;
  4744. /**
  4745. * On center pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnCenterPickTrigger: number;
  4749. /**
  4750. * On pick down
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnPickDownTrigger: number;
  4754. /**
  4755. * On double pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnDoublePickTrigger: number;
  4759. /**
  4760. * On pick up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickUpTrigger: number;
  4764. /**
  4765. * On pick out.
  4766. * This trigger will only be raised if you also declared a OnPickDown
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickOutTrigger: number;
  4770. /**
  4771. * On long press
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnLongPressTrigger: number;
  4775. /**
  4776. * On pointer over
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPointerOverTrigger: number;
  4780. /**
  4781. * On pointer out
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnPointerOutTrigger: number;
  4785. /**
  4786. * On every frame
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnEveryFrameTrigger: number;
  4790. /**
  4791. * On intersection enter
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4795. /**
  4796. * On intersection exit
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnIntersectionExitTrigger: number;
  4800. /**
  4801. * On key down
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnKeyDownTrigger: number;
  4805. /**
  4806. * On key up
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnKeyUpTrigger: number;
  4810. /**
  4811. * Billboard mode will only apply to Y axis
  4812. */
  4813. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4814. /**
  4815. * Billboard mode will apply to all axes
  4816. */
  4817. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4818. /**
  4819. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4820. */
  4821. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4822. /**
  4823. * Gets or sets base Assets URL
  4824. */
  4825. static readonly PARTICLES_BaseAssetsUrl: string;
  4826. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4827. * Test order :
  4828. * Is the bounding sphere outside the frustum ?
  4829. * If not, are the bounding box vertices outside the frustum ?
  4830. * It not, then the cullable object is in the frustum.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4833. /** Culling strategy : Bounding Sphere Only.
  4834. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4835. * It's also less accurate than the standard because some not visible objects can still be selected.
  4836. * Test : is the bounding sphere outside the frustum ?
  4837. * If not, then the cullable object is in the frustum.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4840. /** Culling strategy : Optimistic Inclusion.
  4841. * This in an inclusion test first, then the standard exclusion test.
  4842. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4843. * 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.
  4844. * Anyway, it's as accurate as the standard strategy.
  4845. * Test :
  4846. * Is the cullable object bounding sphere center in the frustum ?
  4847. * If not, apply the default culling strategy.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4850. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4851. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4852. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4860. /**
  4861. * No logging while loading
  4862. */
  4863. static readonly SCENELOADER_NO_LOGGING: number;
  4864. /**
  4865. * Minimal logging while loading
  4866. */
  4867. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4868. /**
  4869. * Summary logging while loading
  4870. */
  4871. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4872. /**
  4873. * Detailled logging while loading
  4874. */
  4875. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4876. }
  4877. }
  4878. declare module BABYLON {
  4879. /**
  4880. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4881. * Babylon.js
  4882. */
  4883. export class DomManagement {
  4884. /**
  4885. * Checks if the window object exists
  4886. * @returns true if the window object exists
  4887. */
  4888. static IsWindowObjectExist(): boolean;
  4889. /**
  4890. * Extracts text content from a DOM element hierarchy
  4891. * @param element defines the root element
  4892. * @returns a string
  4893. */
  4894. static GetDOMTextContent(element: HTMLElement): string;
  4895. }
  4896. }
  4897. declare module BABYLON {
  4898. /**
  4899. * Logger used througouht the application to allow configuration of
  4900. * the log level required for the messages.
  4901. */
  4902. export class Logger {
  4903. /**
  4904. * No log
  4905. */
  4906. static readonly NoneLogLevel: number;
  4907. /**
  4908. * Only message logs
  4909. */
  4910. static readonly MessageLogLevel: number;
  4911. /**
  4912. * Only warning logs
  4913. */
  4914. static readonly WarningLogLevel: number;
  4915. /**
  4916. * Only error logs
  4917. */
  4918. static readonly ErrorLogLevel: number;
  4919. /**
  4920. * All logs
  4921. */
  4922. static readonly AllLogLevel: number;
  4923. private static _LogCache;
  4924. /**
  4925. * Gets a value indicating the number of loading errors
  4926. * @ignorenaming
  4927. */
  4928. static errorsCount: number;
  4929. /**
  4930. * Callback called when a new log is added
  4931. */
  4932. static OnNewCacheEntry: (entry: string) => void;
  4933. private static _AddLogEntry;
  4934. private static _FormatMessage;
  4935. private static _LogDisabled;
  4936. private static _LogEnabled;
  4937. private static _WarnDisabled;
  4938. private static _WarnEnabled;
  4939. private static _ErrorDisabled;
  4940. private static _ErrorEnabled;
  4941. /**
  4942. * Log a message to the console
  4943. */
  4944. static Log: (message: string) => void;
  4945. /**
  4946. * Write a warning message to the console
  4947. */
  4948. static Warn: (message: string) => void;
  4949. /**
  4950. * Write an error message to the console
  4951. */
  4952. static Error: (message: string) => void;
  4953. /**
  4954. * Gets current log cache (list of logs)
  4955. */
  4956. static readonly LogCache: string;
  4957. /**
  4958. * Clears the log cache
  4959. */
  4960. static ClearLogCache(): void;
  4961. /**
  4962. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4963. */
  4964. static LogLevels: number;
  4965. }
  4966. }
  4967. declare module BABYLON {
  4968. /** @hidden */
  4969. export class _TypeStore {
  4970. /** @hidden */
  4971. static RegisteredTypes: {
  4972. [key: string]: Object;
  4973. };
  4974. /** @hidden */
  4975. static GetClass(fqdn: string): any;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * Class containing a set of static utilities functions for deep copy.
  4981. */
  4982. export class DeepCopier {
  4983. /**
  4984. * Tries to copy an object by duplicating every property
  4985. * @param source defines the source object
  4986. * @param destination defines the target object
  4987. * @param doNotCopyList defines a list of properties to avoid
  4988. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4989. */
  4990. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4991. }
  4992. }
  4993. declare module BABYLON {
  4994. /**
  4995. * Class containing a set of static utilities functions for precision date
  4996. */
  4997. export class PrecisionDate {
  4998. /**
  4999. * Gets either window.performance.now() if supported or Date.now() else
  5000. */
  5001. static readonly Now: number;
  5002. }
  5003. }
  5004. declare module BABYLON {
  5005. /** @hidden */
  5006. export class _DevTools {
  5007. static WarnImport(name: string): string;
  5008. }
  5009. }
  5010. declare module BABYLON {
  5011. /**
  5012. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5013. */
  5014. export class WebRequest {
  5015. private _xhr;
  5016. /**
  5017. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5018. * i.e. when loading files, where the server/service expects an Authorization header
  5019. */
  5020. static CustomRequestHeaders: {
  5021. [key: string]: string;
  5022. };
  5023. /**
  5024. * Add callback functions in this array to update all the requests before they get sent to the network
  5025. */
  5026. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5027. private _injectCustomRequestHeaders;
  5028. /**
  5029. * Gets or sets a function to be called when loading progress changes
  5030. */
  5031. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5032. /**
  5033. * Returns client's state
  5034. */
  5035. readonly readyState: number;
  5036. /**
  5037. * Returns client's status
  5038. */
  5039. readonly status: number;
  5040. /**
  5041. * Returns client's status as a text
  5042. */
  5043. readonly statusText: string;
  5044. /**
  5045. * Returns client's response
  5046. */
  5047. readonly response: any;
  5048. /**
  5049. * Returns client's response url
  5050. */
  5051. readonly responseURL: string;
  5052. /**
  5053. * Returns client's response as text
  5054. */
  5055. readonly responseText: string;
  5056. /**
  5057. * Gets or sets the expected response type
  5058. */
  5059. responseType: XMLHttpRequestResponseType;
  5060. /** @hidden */
  5061. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5062. /** @hidden */
  5063. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5064. /**
  5065. * Cancels any network activity
  5066. */
  5067. abort(): void;
  5068. /**
  5069. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5070. * @param body defines an optional request body
  5071. */
  5072. send(body?: Document | BodyInit | null): void;
  5073. /**
  5074. * Sets the request method, request URL
  5075. * @param method defines the method to use (GET, POST, etc..)
  5076. * @param url defines the url to connect with
  5077. */
  5078. open(method: string, url: string): void;
  5079. }
  5080. }
  5081. declare module BABYLON {
  5082. /**
  5083. * Class used to evalaute queries containing `and` and `or` operators
  5084. */
  5085. export class AndOrNotEvaluator {
  5086. /**
  5087. * Evaluate a query
  5088. * @param query defines the query to evaluate
  5089. * @param evaluateCallback defines the callback used to filter result
  5090. * @returns true if the query matches
  5091. */
  5092. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5093. private static _HandleParenthesisContent;
  5094. private static _SimplifyNegation;
  5095. }
  5096. }
  5097. declare module BABYLON {
  5098. /**
  5099. * Class used to store custom tags
  5100. */
  5101. export class Tags {
  5102. /**
  5103. * Adds support for tags on the given object
  5104. * @param obj defines the object to use
  5105. */
  5106. static EnableFor(obj: any): void;
  5107. /**
  5108. * Removes tags support
  5109. * @param obj defines the object to use
  5110. */
  5111. static DisableFor(obj: any): void;
  5112. /**
  5113. * Gets a boolean indicating if the given object has tags
  5114. * @param obj defines the object to use
  5115. * @returns a boolean
  5116. */
  5117. static HasTags(obj: any): boolean;
  5118. /**
  5119. * Gets the tags available on a given object
  5120. * @param obj defines the object to use
  5121. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5122. * @returns the tags
  5123. */
  5124. static GetTags(obj: any, asString?: boolean): any;
  5125. /**
  5126. * Adds tags to an object
  5127. * @param obj defines the object to use
  5128. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5129. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5130. */
  5131. static AddTagsTo(obj: any, tagsString: string): void;
  5132. /**
  5133. * @hidden
  5134. */ private static _AddTagTo(obj: any, tag: string): void;
  5135. /**
  5136. * Removes specific tags from a specific object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tags to remove
  5139. */
  5140. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5141. /**
  5142. * @hidden
  5143. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5144. /**
  5145. * Defines if tags hosted on an object match a given query
  5146. * @param obj defines the object to use
  5147. * @param tagsQuery defines the tag query
  5148. * @returns a boolean
  5149. */
  5150. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5151. }
  5152. }
  5153. declare module BABYLON {
  5154. /**
  5155. * Manages the defines for the Material
  5156. */
  5157. export class MaterialDefines {
  5158. /** @hidden */
  5159. protected _keys: string[];
  5160. private _isDirty;
  5161. /** @hidden */ private _renderId: number;
  5162. /** @hidden */ private _areLightsDirty: boolean;
  5163. /** @hidden */ private _areAttributesDirty: boolean;
  5164. /** @hidden */ private _areTexturesDirty: boolean;
  5165. /** @hidden */ private _areFresnelDirty: boolean;
  5166. /** @hidden */ private _areMiscDirty: boolean;
  5167. /** @hidden */ private _areImageProcessingDirty: boolean;
  5168. /** @hidden */ private _normals: boolean;
  5169. /** @hidden */ private _uvs: boolean;
  5170. /** @hidden */ private _needNormals: boolean;
  5171. /** @hidden */ private _needUVs: boolean;
  5172. [id: string]: any;
  5173. /**
  5174. * Specifies if the material needs to be re-calculated
  5175. */
  5176. readonly isDirty: boolean;
  5177. /**
  5178. * Marks the material to indicate that it has been re-calculated
  5179. */
  5180. markAsProcessed(): void;
  5181. /**
  5182. * Marks the material to indicate that it needs to be re-calculated
  5183. */
  5184. markAsUnprocessed(): void;
  5185. /**
  5186. * Marks the material to indicate all of its defines need to be re-calculated
  5187. */
  5188. markAllAsDirty(): void;
  5189. /**
  5190. * Marks the material to indicate that image processing needs to be re-calculated
  5191. */
  5192. markAsImageProcessingDirty(): void;
  5193. /**
  5194. * Marks the material to indicate the lights need to be re-calculated
  5195. */
  5196. markAsLightDirty(): void;
  5197. /**
  5198. * Marks the attribute state as changed
  5199. */
  5200. markAsAttributesDirty(): void;
  5201. /**
  5202. * Marks the texture state as changed
  5203. */
  5204. markAsTexturesDirty(): void;
  5205. /**
  5206. * Marks the fresnel state as changed
  5207. */
  5208. markAsFresnelDirty(): void;
  5209. /**
  5210. * Marks the misc state as changed
  5211. */
  5212. markAsMiscDirty(): void;
  5213. /**
  5214. * Rebuilds the material defines
  5215. */
  5216. rebuild(): void;
  5217. /**
  5218. * Specifies if two material defines are equal
  5219. * @param other - A material define instance to compare to
  5220. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5221. */
  5222. isEqual(other: MaterialDefines): boolean;
  5223. /**
  5224. * Clones this instance's defines to another instance
  5225. * @param other - material defines to clone values to
  5226. */
  5227. cloneTo(other: MaterialDefines): void;
  5228. /**
  5229. * Resets the material define values
  5230. */
  5231. reset(): void;
  5232. /**
  5233. * Converts the material define values to a string
  5234. * @returns - String of material define information
  5235. */
  5236. toString(): string;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. /**
  5241. * Class used to store and describe the pipeline context associated with an effect
  5242. */
  5243. export interface IPipelineContext {
  5244. /**
  5245. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5246. */
  5247. isAsync: boolean;
  5248. /**
  5249. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5250. */
  5251. isReady: boolean;
  5252. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store gfx data (like WebGLBuffer)
  5258. */
  5259. export class DataBuffer {
  5260. /**
  5261. * Gets or sets the number of objects referencing this buffer
  5262. */
  5263. references: number;
  5264. /** Gets or sets the size of the underlying buffer */
  5265. capacity: number;
  5266. /**
  5267. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5268. */
  5269. is32Bits: boolean;
  5270. /**
  5271. * Gets the underlying buffer
  5272. */
  5273. readonly underlyingResource: any;
  5274. }
  5275. }
  5276. declare module BABYLON {
  5277. /**
  5278. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5279. */
  5280. export class PerformanceMonitor {
  5281. private _enabled;
  5282. private _rollingFrameTime;
  5283. private _lastFrameTimeMs;
  5284. /**
  5285. * constructor
  5286. * @param frameSampleSize The number of samples required to saturate the sliding window
  5287. */
  5288. constructor(frameSampleSize?: number);
  5289. /**
  5290. * Samples current frame
  5291. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5292. */
  5293. sampleFrame(timeMs?: number): void;
  5294. /**
  5295. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5296. */
  5297. readonly averageFrameTime: number;
  5298. /**
  5299. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5300. */
  5301. readonly averageFrameTimeVariance: number;
  5302. /**
  5303. * Returns the frame time of the most recent frame
  5304. */
  5305. readonly instantaneousFrameTime: number;
  5306. /**
  5307. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5308. */
  5309. readonly averageFPS: number;
  5310. /**
  5311. * Returns the average framerate in frames per second using the most recent frame time
  5312. */
  5313. readonly instantaneousFPS: number;
  5314. /**
  5315. * Returns true if enough samples have been taken to completely fill the sliding window
  5316. */
  5317. readonly isSaturated: boolean;
  5318. /**
  5319. * Enables contributions to the sliding window sample set
  5320. */
  5321. enable(): void;
  5322. /**
  5323. * Disables contributions to the sliding window sample set
  5324. * Samples will not be interpolated over the disabled period
  5325. */
  5326. disable(): void;
  5327. /**
  5328. * Returns true if sampling is enabled
  5329. */
  5330. readonly isEnabled: boolean;
  5331. /**
  5332. * Resets performance monitor
  5333. */
  5334. reset(): void;
  5335. }
  5336. /**
  5337. * RollingAverage
  5338. *
  5339. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5340. */
  5341. export class RollingAverage {
  5342. /**
  5343. * Current average
  5344. */
  5345. average: number;
  5346. /**
  5347. * Current variance
  5348. */
  5349. variance: number;
  5350. protected _samples: Array<number>;
  5351. protected _sampleCount: number;
  5352. protected _pos: number;
  5353. protected _m2: number;
  5354. /**
  5355. * constructor
  5356. * @param length The number of samples required to saturate the sliding window
  5357. */
  5358. constructor(length: number);
  5359. /**
  5360. * Adds a sample to the sample set
  5361. * @param v The sample value
  5362. */
  5363. add(v: number): void;
  5364. /**
  5365. * Returns previously added values or null if outside of history or outside the sliding window domain
  5366. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5367. * @return Value previously recorded with add() or null if outside of range
  5368. */
  5369. history(i: number): number;
  5370. /**
  5371. * Returns true if enough samples have been taken to completely fill the sliding window
  5372. * @return true if sample-set saturated
  5373. */
  5374. isSaturated(): boolean;
  5375. /**
  5376. * Resets the rolling average (equivalent to 0 samples taken so far)
  5377. */
  5378. reset(): void;
  5379. /**
  5380. * Wraps a value around the sample range boundaries
  5381. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5382. * @return Wrapped position in sample range
  5383. */
  5384. protected _wrapPosition(i: number): number;
  5385. }
  5386. }
  5387. declare module BABYLON {
  5388. /**
  5389. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5390. * The underlying implementation relies on an associative array to ensure the best performances.
  5391. * The value can be anything including 'null' but except 'undefined'
  5392. */
  5393. export class StringDictionary<T> {
  5394. /**
  5395. * This will clear this dictionary and copy the content from the 'source' one.
  5396. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5397. * @param source the dictionary to take the content from and copy to this dictionary
  5398. */
  5399. copyFrom(source: StringDictionary<T>): void;
  5400. /**
  5401. * Get a value based from its key
  5402. * @param key the given key to get the matching value from
  5403. * @return the value if found, otherwise undefined is returned
  5404. */
  5405. get(key: string): T | undefined;
  5406. /**
  5407. * Get a value from its key or add it if it doesn't exist.
  5408. * This method will ensure you that a given key/data will be present in the dictionary.
  5409. * @param key the given key to get the matching value from
  5410. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5411. * The factory will only be invoked if there's no data for the given key.
  5412. * @return the value corresponding to the key.
  5413. */
  5414. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5415. /**
  5416. * Get a value from its key if present in the dictionary otherwise add it
  5417. * @param key the key to get the value from
  5418. * @param val if there's no such key/value pair in the dictionary add it with this value
  5419. * @return the value corresponding to the key
  5420. */
  5421. getOrAdd(key: string, val: T): T;
  5422. /**
  5423. * Check if there's a given key in the dictionary
  5424. * @param key the key to check for
  5425. * @return true if the key is present, false otherwise
  5426. */
  5427. contains(key: string): boolean;
  5428. /**
  5429. * Add a new key and its corresponding value
  5430. * @param key the key to add
  5431. * @param value the value corresponding to the key
  5432. * @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
  5433. */
  5434. add(key: string, value: T): boolean;
  5435. /**
  5436. * Update a specific value associated to a key
  5437. * @param key defines the key to use
  5438. * @param value defines the value to store
  5439. * @returns true if the value was updated (or false if the key was not found)
  5440. */
  5441. set(key: string, value: T): boolean;
  5442. /**
  5443. * Get the element of the given key and remove it from the dictionary
  5444. * @param key defines the key to search
  5445. * @returns the value associated with the key or null if not found
  5446. */
  5447. getAndRemove(key: string): Nullable<T>;
  5448. /**
  5449. * Remove a key/value from the dictionary.
  5450. * @param key the key to remove
  5451. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5452. */
  5453. remove(key: string): boolean;
  5454. /**
  5455. * Clear the whole content of the dictionary
  5456. */
  5457. clear(): void;
  5458. /**
  5459. * Gets the current count
  5460. */
  5461. readonly count: number;
  5462. /**
  5463. * Execute a callback on each key/val of the dictionary.
  5464. * Note that you can remove any element in this dictionary in the callback implementation
  5465. * @param callback the callback to execute on a given key/value pair
  5466. */
  5467. forEach(callback: (key: string, val: T) => void): void;
  5468. /**
  5469. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5470. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5471. * Note that you can remove any element in this dictionary in the callback implementation
  5472. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5473. * @returns the first item
  5474. */
  5475. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5476. private _count;
  5477. private _data;
  5478. }
  5479. }
  5480. declare module BABYLON {
  5481. /**
  5482. * Helper class that provides a small promise polyfill
  5483. */
  5484. export class PromisePolyfill {
  5485. /**
  5486. * Static function used to check if the polyfill is required
  5487. * If this is the case then the function will inject the polyfill to window.Promise
  5488. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5489. */
  5490. static Apply(force?: boolean): void;
  5491. }
  5492. }
  5493. declare module BABYLON {
  5494. /**
  5495. * Class used to store data that will be store in GPU memory
  5496. */
  5497. export class Buffer {
  5498. private _engine;
  5499. private _buffer;
  5500. /** @hidden */ private _data: Nullable<DataArray>;
  5501. private _updatable;
  5502. private _instanced;
  5503. /**
  5504. * Gets the byte stride.
  5505. */
  5506. readonly byteStride: number;
  5507. /**
  5508. * Constructor
  5509. * @param engine the engine
  5510. * @param data the data to use for this buffer
  5511. * @param updatable whether the data is updatable
  5512. * @param stride the stride (optional)
  5513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5514. * @param instanced whether the buffer is instanced (optional)
  5515. * @param useBytes set to true if the stride in in bytes (optional)
  5516. */
  5517. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5518. /**
  5519. * Create a new VertexBuffer based on the current buffer
  5520. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5521. * @param offset defines offset in the buffer (0 by default)
  5522. * @param size defines the size in floats of attributes (position is 3 for instance)
  5523. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5524. * @param instanced defines if the vertex buffer contains indexed data
  5525. * @param useBytes defines if the offset and stride are in bytes
  5526. * @returns the new vertex buffer
  5527. */
  5528. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5529. /**
  5530. * Gets a boolean indicating if the Buffer is updatable?
  5531. * @returns true if the buffer is updatable
  5532. */
  5533. isUpdatable(): boolean;
  5534. /**
  5535. * Gets current buffer's data
  5536. * @returns a DataArray or null
  5537. */
  5538. getData(): Nullable<DataArray>;
  5539. /**
  5540. * Gets underlying native buffer
  5541. * @returns underlying native buffer
  5542. */
  5543. getBuffer(): Nullable<DataBuffer>;
  5544. /**
  5545. * Gets the stride in float32 units (i.e. byte stride / 4).
  5546. * May not be an integer if the byte stride is not divisible by 4.
  5547. * DEPRECATED. Use byteStride instead.
  5548. * @returns the stride in float32 units
  5549. */
  5550. getStrideSize(): number;
  5551. /**
  5552. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5553. * @param data defines the data to store
  5554. */
  5555. create(data?: Nullable<DataArray>): void;
  5556. /** @hidden */ private _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */ private _buffer: Buffer;
  5580. private _kind;
  5581. private _size;
  5582. private _ownsBuffer;
  5583. private _instanced;
  5584. private _instanceDivisor;
  5585. /**
  5586. * The byte type.
  5587. */
  5588. static readonly BYTE: number;
  5589. /**
  5590. * The unsigned byte type.
  5591. */
  5592. static readonly UNSIGNED_BYTE: number;
  5593. /**
  5594. * The short type.
  5595. */
  5596. static readonly SHORT: number;
  5597. /**
  5598. * The unsigned short type.
  5599. */
  5600. static readonly UNSIGNED_SHORT: number;
  5601. /**
  5602. * The integer type.
  5603. */
  5604. static readonly INT: number;
  5605. /**
  5606. * The unsigned integer type.
  5607. */
  5608. static readonly UNSIGNED_INT: number;
  5609. /**
  5610. * The float type.
  5611. */
  5612. static readonly FLOAT: number;
  5613. /**
  5614. * Gets or sets the instance divisor when in instanced mode
  5615. */
  5616. instanceDivisor: number;
  5617. /**
  5618. * Gets the byte stride.
  5619. */
  5620. readonly byteStride: number;
  5621. /**
  5622. * Gets the byte offset.
  5623. */
  5624. readonly byteOffset: number;
  5625. /**
  5626. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5627. */
  5628. readonly normalized: boolean;
  5629. /**
  5630. * Gets the data type of each component in the array.
  5631. */
  5632. readonly type: number;
  5633. /**
  5634. * Constructor
  5635. * @param engine the engine
  5636. * @param data the data to use for this vertex buffer
  5637. * @param kind the vertex buffer kind
  5638. * @param updatable whether the data is updatable
  5639. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5640. * @param stride the stride (optional)
  5641. * @param instanced whether the buffer is instanced (optional)
  5642. * @param offset the offset of the data (optional)
  5643. * @param size the number of components (optional)
  5644. * @param type the type of the component (optional)
  5645. * @param normalized whether the data contains normalized data (optional)
  5646. * @param useBytes set to true if stride and offset are in bytes (optional)
  5647. */
  5648. 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);
  5649. /** @hidden */ private _rebuild(): void;
  5650. /**
  5651. * Returns the kind of the VertexBuffer (string)
  5652. * @returns a string
  5653. */
  5654. getKind(): string;
  5655. /**
  5656. * Gets a boolean indicating if the VertexBuffer is updatable?
  5657. * @returns true if the buffer is updatable
  5658. */
  5659. isUpdatable(): boolean;
  5660. /**
  5661. * Gets current buffer's data
  5662. * @returns a DataArray or null
  5663. */
  5664. getData(): Nullable<DataArray>;
  5665. /**
  5666. * Gets underlying native buffer
  5667. * @returns underlying native buffer
  5668. */
  5669. getBuffer(): Nullable<DataBuffer>;
  5670. /**
  5671. * Gets the stride in float32 units (i.e. byte stride / 4).
  5672. * May not be an integer if the byte stride is not divisible by 4.
  5673. * DEPRECATED. Use byteStride instead.
  5674. * @returns the stride in float32 units
  5675. */
  5676. getStrideSize(): number;
  5677. /**
  5678. * Returns the offset as a multiple of the type byte length.
  5679. * DEPRECATED. Use byteOffset instead.
  5680. * @returns the offset in bytes
  5681. */
  5682. getOffset(): number;
  5683. /**
  5684. * Returns the number of components per vertex attribute (integer)
  5685. * @returns the size in float
  5686. */
  5687. getSize(): number;
  5688. /**
  5689. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5690. * @returns true if this buffer is instanced
  5691. */
  5692. getIsInstanced(): boolean;
  5693. /**
  5694. * Returns the instancing divisor, zero for non-instanced (integer).
  5695. * @returns a number
  5696. */
  5697. getInstanceDivisor(): number;
  5698. /**
  5699. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5700. * @param data defines the data to store
  5701. */
  5702. create(data?: DataArray): void;
  5703. /**
  5704. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5705. * This function will create a new buffer if the current one is not updatable
  5706. * @param data defines the data to store
  5707. */
  5708. update(data: DataArray): void;
  5709. /**
  5710. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5711. * Returns the directly updated WebGLBuffer.
  5712. * @param data the new data
  5713. * @param offset the new offset
  5714. * @param useBytes set to true if the offset is in bytes
  5715. */
  5716. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5717. /**
  5718. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5719. */
  5720. dispose(): void;
  5721. /**
  5722. * Enumerates each value of this vertex buffer as numbers.
  5723. * @param count the number of values to enumerate
  5724. * @param callback the callback function called for each value
  5725. */
  5726. forEach(count: number, callback: (value: number, index: number) => void): void;
  5727. /**
  5728. * Positions
  5729. */
  5730. static readonly PositionKind: string;
  5731. /**
  5732. * Normals
  5733. */
  5734. static readonly NormalKind: string;
  5735. /**
  5736. * Tangents
  5737. */
  5738. static readonly TangentKind: string;
  5739. /**
  5740. * Texture coordinates
  5741. */
  5742. static readonly UVKind: string;
  5743. /**
  5744. * Texture coordinates 2
  5745. */
  5746. static readonly UV2Kind: string;
  5747. /**
  5748. * Texture coordinates 3
  5749. */
  5750. static readonly UV3Kind: string;
  5751. /**
  5752. * Texture coordinates 4
  5753. */
  5754. static readonly UV4Kind: string;
  5755. /**
  5756. * Texture coordinates 5
  5757. */
  5758. static readonly UV5Kind: string;
  5759. /**
  5760. * Texture coordinates 6
  5761. */
  5762. static readonly UV6Kind: string;
  5763. /**
  5764. * Colors
  5765. */
  5766. static readonly ColorKind: string;
  5767. /**
  5768. * Matrix indices (for bones)
  5769. */
  5770. static readonly MatricesIndicesKind: string;
  5771. /**
  5772. * Matrix weights (for bones)
  5773. */
  5774. static readonly MatricesWeightsKind: string;
  5775. /**
  5776. * Additional matrix indices (for bones)
  5777. */
  5778. static readonly MatricesIndicesExtraKind: string;
  5779. /**
  5780. * Additional matrix weights (for bones)
  5781. */
  5782. static readonly MatricesWeightsExtraKind: string;
  5783. /**
  5784. * Deduces the stride given a kind.
  5785. * @param kind The kind string to deduce
  5786. * @returns The deduced stride
  5787. */
  5788. static DeduceStride(kind: string): number;
  5789. /**
  5790. * Gets the byte length of the given type.
  5791. * @param type the type
  5792. * @returns the number of bytes
  5793. */
  5794. static GetTypeByteLength(type: number): number;
  5795. /**
  5796. * Enumerates each value of the given parameters as numbers.
  5797. * @param data the data to enumerate
  5798. * @param byteOffset the byte offset of the data
  5799. * @param byteStride the byte stride of the data
  5800. * @param componentCount the number of components per element
  5801. * @param componentType the type of the component
  5802. * @param count the total number of components
  5803. * @param normalized whether the data is normalized
  5804. * @param callback the callback function called for each value
  5805. */
  5806. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5807. private static _GetFloatValue;
  5808. }
  5809. }
  5810. declare module BABYLON {
  5811. /**
  5812. * Class representing spherical harmonics coefficients to the 3rd degree
  5813. */
  5814. export class SphericalHarmonics {
  5815. /**
  5816. * Defines whether or not the harmonics have been prescaled for rendering.
  5817. */
  5818. preScaled: boolean;
  5819. /**
  5820. * The l0,0 coefficients of the spherical harmonics
  5821. */
  5822. l00: Vector3;
  5823. /**
  5824. * The l1,-1 coefficients of the spherical harmonics
  5825. */
  5826. l1_1: Vector3;
  5827. /**
  5828. * The l1,0 coefficients of the spherical harmonics
  5829. */
  5830. l10: Vector3;
  5831. /**
  5832. * The l1,1 coefficients of the spherical harmonics
  5833. */
  5834. l11: Vector3;
  5835. /**
  5836. * The l2,-2 coefficients of the spherical harmonics
  5837. */
  5838. l2_2: Vector3;
  5839. /**
  5840. * The l2,-1 coefficients of the spherical harmonics
  5841. */
  5842. l2_1: Vector3;
  5843. /**
  5844. * The l2,0 coefficients of the spherical harmonics
  5845. */
  5846. l20: Vector3;
  5847. /**
  5848. * The l2,1 coefficients of the spherical harmonics
  5849. */
  5850. l21: Vector3;
  5851. /**
  5852. * The l2,2 coefficients of the spherical harmonics
  5853. */
  5854. l22: Vector3;
  5855. /**
  5856. * Adds a light to the spherical harmonics
  5857. * @param direction the direction of the light
  5858. * @param color the color of the light
  5859. * @param deltaSolidAngle the delta solid angle of the light
  5860. */
  5861. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5862. /**
  5863. * Scales the spherical harmonics by the given amount
  5864. * @param scale the amount to scale
  5865. */
  5866. scaleInPlace(scale: number): void;
  5867. /**
  5868. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5869. *
  5870. * ```
  5871. * E_lm = A_l * L_lm
  5872. * ```
  5873. *
  5874. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5875. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5876. * the scaling factors are given in equation 9.
  5877. */
  5878. convertIncidentRadianceToIrradiance(): void;
  5879. /**
  5880. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5881. *
  5882. * ```
  5883. * L = (1/pi) * E * rho
  5884. * ```
  5885. *
  5886. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5887. */
  5888. convertIrradianceToLambertianRadiance(): void;
  5889. /**
  5890. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5891. * required operations at run time.
  5892. *
  5893. * This is simply done by scaling back the SH with Ylm constants parameter.
  5894. * The trigonometric part being applied by the shader at run time.
  5895. */
  5896. preScaleForRendering(): void;
  5897. /**
  5898. * Constructs a spherical harmonics from an array.
  5899. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5900. * @returns the spherical harmonics
  5901. */
  5902. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5903. /**
  5904. * Gets the spherical harmonics from polynomial
  5905. * @param polynomial the spherical polynomial
  5906. * @returns the spherical harmonics
  5907. */
  5908. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5909. }
  5910. /**
  5911. * Class representing spherical polynomial coefficients to the 3rd degree
  5912. */
  5913. export class SphericalPolynomial {
  5914. private _harmonics;
  5915. /**
  5916. * The spherical harmonics used to create the polynomials.
  5917. */
  5918. readonly preScaledHarmonics: SphericalHarmonics;
  5919. /**
  5920. * The x coefficients of the spherical polynomial
  5921. */
  5922. x: Vector3;
  5923. /**
  5924. * The y coefficients of the spherical polynomial
  5925. */
  5926. y: Vector3;
  5927. /**
  5928. * The z coefficients of the spherical polynomial
  5929. */
  5930. z: Vector3;
  5931. /**
  5932. * The xx coefficients of the spherical polynomial
  5933. */
  5934. xx: Vector3;
  5935. /**
  5936. * The yy coefficients of the spherical polynomial
  5937. */
  5938. yy: Vector3;
  5939. /**
  5940. * The zz coefficients of the spherical polynomial
  5941. */
  5942. zz: Vector3;
  5943. /**
  5944. * The xy coefficients of the spherical polynomial
  5945. */
  5946. xy: Vector3;
  5947. /**
  5948. * The yz coefficients of the spherical polynomial
  5949. */
  5950. yz: Vector3;
  5951. /**
  5952. * The zx coefficients of the spherical polynomial
  5953. */
  5954. zx: Vector3;
  5955. /**
  5956. * Adds an ambient color to the spherical polynomial
  5957. * @param color the color to add
  5958. */
  5959. addAmbient(color: Color3): void;
  5960. /**
  5961. * Scales the spherical polynomial by the given amount
  5962. * @param scale the amount to scale
  5963. */
  5964. scaleInPlace(scale: number): void;
  5965. /**
  5966. * Gets the spherical polynomial from harmonics
  5967. * @param harmonics the spherical harmonics
  5968. * @returns the spherical polynomial
  5969. */
  5970. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5971. /**
  5972. * Constructs a spherical polynomial from an array.
  5973. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5974. * @returns the spherical polynomial
  5975. */
  5976. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5977. }
  5978. }
  5979. declare module BABYLON {
  5980. /**
  5981. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5982. */
  5983. export interface CubeMapInfo {
  5984. /**
  5985. * The pixel array for the front face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. front: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The pixel array for the back face.
  5991. * This is stored in format, left to right, up to down format.
  5992. */
  5993. back: Nullable<ArrayBufferView>;
  5994. /**
  5995. * The pixel array for the left face.
  5996. * This is stored in format, left to right, up to down format.
  5997. */
  5998. left: Nullable<ArrayBufferView>;
  5999. /**
  6000. * The pixel array for the right face.
  6001. * This is stored in format, left to right, up to down format.
  6002. */
  6003. right: Nullable<ArrayBufferView>;
  6004. /**
  6005. * The pixel array for the up face.
  6006. * This is stored in format, left to right, up to down format.
  6007. */
  6008. up: Nullable<ArrayBufferView>;
  6009. /**
  6010. * The pixel array for the down face.
  6011. * This is stored in format, left to right, up to down format.
  6012. */
  6013. down: Nullable<ArrayBufferView>;
  6014. /**
  6015. * The size of the cubemap stored.
  6016. *
  6017. * Each faces will be size * size pixels.
  6018. */
  6019. size: number;
  6020. /**
  6021. * The format of the texture.
  6022. *
  6023. * RGBA, RGB.
  6024. */
  6025. format: number;
  6026. /**
  6027. * The type of the texture data.
  6028. *
  6029. * UNSIGNED_INT, FLOAT.
  6030. */
  6031. type: number;
  6032. /**
  6033. * Specifies whether the texture is in gamma space.
  6034. */
  6035. gammaSpace: boolean;
  6036. }
  6037. /**
  6038. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6039. */
  6040. export class PanoramaToCubeMapTools {
  6041. private static FACE_FRONT;
  6042. private static FACE_BACK;
  6043. private static FACE_RIGHT;
  6044. private static FACE_LEFT;
  6045. private static FACE_DOWN;
  6046. private static FACE_UP;
  6047. /**
  6048. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6049. *
  6050. * @param float32Array The source data.
  6051. * @param inputWidth The width of the input panorama.
  6052. * @param inputHeight The height of the input panorama.
  6053. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6054. * @return The cubemap data
  6055. */
  6056. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6057. private static CreateCubemapTexture;
  6058. private static CalcProjectionSpherical;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * Helper class dealing with the extraction of spherical polynomial dataArray
  6064. * from a cube map.
  6065. */
  6066. export class CubeMapToSphericalPolynomialTools {
  6067. private static FileFaces;
  6068. /**
  6069. * Converts a texture to the according Spherical Polynomial data.
  6070. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6071. *
  6072. * @param texture The texture to extract the information from.
  6073. * @return The Spherical Polynomial data.
  6074. */
  6075. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6076. /**
  6077. * Converts a cubemap to the according Spherical Polynomial data.
  6078. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6079. *
  6080. * @param cubeInfo The Cube map to extract the information from.
  6081. * @return The Spherical Polynomial data.
  6082. */
  6083. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6084. }
  6085. }
  6086. declare module BABYLON {
  6087. /**
  6088. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6089. * during the life time of the application.
  6090. */
  6091. export class EngineStore {
  6092. /** Gets the list of created engines */
  6093. static Instances: Engine[];
  6094. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  6095. /**
  6096. * Gets the latest created engine
  6097. */
  6098. static readonly LastCreatedEngine: Nullable<Engine>;
  6099. /**
  6100. * Gets the latest created scene
  6101. */
  6102. static readonly LastCreatedScene: Nullable<Scene>;
  6103. }
  6104. }
  6105. declare module BABYLON {
  6106. /**
  6107. * Define options used to create a render target texture
  6108. */
  6109. export class RenderTargetCreationOptions {
  6110. /**
  6111. * Specifies is mipmaps must be generated
  6112. */
  6113. generateMipMaps?: boolean;
  6114. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6115. generateDepthBuffer?: boolean;
  6116. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6117. generateStencilBuffer?: boolean;
  6118. /** Defines texture type (int by default) */
  6119. type?: number;
  6120. /** Defines sampling mode (trilinear by default) */
  6121. samplingMode?: number;
  6122. /** Defines format (RGBA by default) */
  6123. format?: number;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @hidden
  6129. **/
  6130. export class _AlphaState {
  6131. private _isAlphaBlendDirty;
  6132. private _isBlendFunctionParametersDirty;
  6133. private _isBlendEquationParametersDirty;
  6134. private _isBlendConstantsDirty;
  6135. private _alphaBlend;
  6136. private _blendFunctionParameters;
  6137. private _blendEquationParameters;
  6138. private _blendConstants;
  6139. /**
  6140. * Initializes the state.
  6141. */
  6142. constructor();
  6143. readonly isDirty: boolean;
  6144. alphaBlend: boolean;
  6145. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6146. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6147. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6148. reset(): void;
  6149. apply(gl: WebGLRenderingContext): void;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * @hidden
  6155. **/
  6156. export class _DepthCullingState {
  6157. private _isDepthTestDirty;
  6158. private _isDepthMaskDirty;
  6159. private _isDepthFuncDirty;
  6160. private _isCullFaceDirty;
  6161. private _isCullDirty;
  6162. private _isZOffsetDirty;
  6163. private _isFrontFaceDirty;
  6164. private _depthTest;
  6165. private _depthMask;
  6166. private _depthFunc;
  6167. private _cull;
  6168. private _cullFace;
  6169. private _zOffset;
  6170. private _frontFace;
  6171. /**
  6172. * Initializes the state.
  6173. */
  6174. constructor();
  6175. readonly isDirty: boolean;
  6176. zOffset: number;
  6177. cullFace: Nullable<number>;
  6178. cull: Nullable<boolean>;
  6179. depthFunc: Nullable<number>;
  6180. depthMask: boolean;
  6181. depthTest: boolean;
  6182. frontFace: Nullable<number>;
  6183. reset(): void;
  6184. apply(gl: WebGLRenderingContext): void;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * @hidden
  6190. **/
  6191. export class _StencilState {
  6192. /** 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 */
  6193. static readonly ALWAYS: number;
  6194. /** Passed to stencilOperation to specify that stencil value must be kept */
  6195. static readonly KEEP: number;
  6196. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6197. static readonly REPLACE: number;
  6198. private _isStencilTestDirty;
  6199. private _isStencilMaskDirty;
  6200. private _isStencilFuncDirty;
  6201. private _isStencilOpDirty;
  6202. private _stencilTest;
  6203. private _stencilMask;
  6204. private _stencilFunc;
  6205. private _stencilFuncRef;
  6206. private _stencilFuncMask;
  6207. private _stencilOpStencilFail;
  6208. private _stencilOpDepthFail;
  6209. private _stencilOpStencilDepthPass;
  6210. readonly isDirty: boolean;
  6211. stencilFunc: number;
  6212. stencilFuncRef: number;
  6213. stencilFuncMask: number;
  6214. stencilOpStencilFail: number;
  6215. stencilOpDepthFail: number;
  6216. stencilOpStencilDepthPass: number;
  6217. stencilMask: number;
  6218. stencilTest: boolean;
  6219. constructor();
  6220. reset(): void;
  6221. apply(gl: WebGLRenderingContext): void;
  6222. }
  6223. }
  6224. declare module BABYLON {
  6225. /**
  6226. * @hidden
  6227. **/
  6228. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Class used to store data associated with WebGL texture data for the engine
  6234. * This class should not be used directly
  6235. */
  6236. export class InternalTexture {
  6237. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6238. /**
  6239. * The source of the texture data is unknown
  6240. */
  6241. static DATASOURCE_UNKNOWN: number;
  6242. /**
  6243. * Texture data comes from an URL
  6244. */
  6245. static DATASOURCE_URL: number;
  6246. /**
  6247. * Texture data is only used for temporary storage
  6248. */
  6249. static DATASOURCE_TEMP: number;
  6250. /**
  6251. * Texture data comes from raw data (ArrayBuffer)
  6252. */
  6253. static DATASOURCE_RAW: number;
  6254. /**
  6255. * Texture content is dynamic (video or dynamic texture)
  6256. */
  6257. static DATASOURCE_DYNAMIC: number;
  6258. /**
  6259. * Texture content is generated by rendering to it
  6260. */
  6261. static DATASOURCE_RENDERTARGET: number;
  6262. /**
  6263. * Texture content is part of a multi render target process
  6264. */
  6265. static DATASOURCE_MULTIRENDERTARGET: number;
  6266. /**
  6267. * Texture data comes from a cube data file
  6268. */
  6269. static DATASOURCE_CUBE: number;
  6270. /**
  6271. * Texture data comes from a raw cube data
  6272. */
  6273. static DATASOURCE_CUBERAW: number;
  6274. /**
  6275. * Texture data come from a prefiltered cube data file
  6276. */
  6277. static DATASOURCE_CUBEPREFILTERED: number;
  6278. /**
  6279. * Texture content is raw 3D data
  6280. */
  6281. static DATASOURCE_RAW3D: number;
  6282. /**
  6283. * Texture content is a depth texture
  6284. */
  6285. static DATASOURCE_DEPTHTEXTURE: number;
  6286. /**
  6287. * Texture data comes from a raw cube data encoded with RGBD
  6288. */
  6289. static DATASOURCE_CUBERAW_RGBD: number;
  6290. /**
  6291. * Defines if the texture is ready
  6292. */
  6293. isReady: boolean;
  6294. /**
  6295. * Defines if the texture is a cube texture
  6296. */
  6297. isCube: boolean;
  6298. /**
  6299. * Defines if the texture contains 3D data
  6300. */
  6301. is3D: boolean;
  6302. /**
  6303. * Defines if the texture contains multiview data
  6304. */
  6305. isMultiview: boolean;
  6306. /**
  6307. * Gets the URL used to load this texture
  6308. */
  6309. url: string;
  6310. /**
  6311. * Gets the sampling mode of the texture
  6312. */
  6313. samplingMode: number;
  6314. /**
  6315. * Gets a boolean indicating if the texture needs mipmaps generation
  6316. */
  6317. generateMipMaps: boolean;
  6318. /**
  6319. * Gets the number of samples used by the texture (WebGL2+ only)
  6320. */
  6321. samples: number;
  6322. /**
  6323. * Gets the type of the texture (int, float...)
  6324. */
  6325. type: number;
  6326. /**
  6327. * Gets the format of the texture (RGB, RGBA...)
  6328. */
  6329. format: number;
  6330. /**
  6331. * Observable called when the texture is loaded
  6332. */
  6333. onLoadedObservable: Observable<InternalTexture>;
  6334. /**
  6335. * Gets the width of the texture
  6336. */
  6337. width: number;
  6338. /**
  6339. * Gets the height of the texture
  6340. */
  6341. height: number;
  6342. /**
  6343. * Gets the depth of the texture
  6344. */
  6345. depth: number;
  6346. /**
  6347. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6348. */
  6349. baseWidth: number;
  6350. /**
  6351. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6352. */
  6353. baseHeight: number;
  6354. /**
  6355. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6356. */
  6357. baseDepth: number;
  6358. /**
  6359. * Gets a boolean indicating if the texture is inverted on Y axis
  6360. */
  6361. invertY: boolean;
  6362. /** @hidden */ private _invertVScale: boolean;
  6363. /** @hidden */ private _associatedChannel: number;
  6364. /** @hidden */ private _dataSource: number;
  6365. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6366. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  6367. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  6368. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */ private _size: number;
  6370. /** @hidden */ private _extension: string;
  6371. /** @hidden */ private _files: Nullable<string[]>;
  6372. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  6373. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  6374. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  6375. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6376. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6377. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6378. /** @hidden */ private _attachments: Nullable<number[]>;
  6379. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  6380. /** @hidden */ private _cachedWrapU: Nullable<number>;
  6381. /** @hidden */ private _cachedWrapV: Nullable<number>;
  6382. /** @hidden */ private _cachedWrapR: Nullable<number>;
  6383. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  6384. /** @hidden */ private _isDisabled: boolean;
  6385. /** @hidden */ private _compression: Nullable<string>;
  6386. /** @hidden */ private _generateStencilBuffer: boolean;
  6387. /** @hidden */ private _generateDepthBuffer: boolean;
  6388. /** @hidden */ private _comparisonFunction: number;
  6389. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6390. /** @hidden */ private _lodGenerationScale: number;
  6391. /** @hidden */ private _lodGenerationOffset: number;
  6392. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  6393. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  6395. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  6396. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  6397. /** @hidden */ private _isRGBD: boolean;
  6398. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  6399. /** @hidden */ private _references: number;
  6400. private _engine;
  6401. /**
  6402. * Gets the Engine the texture belongs to.
  6403. * @returns The babylon engine
  6404. */
  6405. getEngine(): Engine;
  6406. /**
  6407. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6408. */
  6409. readonly dataSource: number;
  6410. /**
  6411. * Creates a new InternalTexture
  6412. * @param engine defines the engine to use
  6413. * @param dataSource defines the type of data that will be used
  6414. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6415. */
  6416. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6417. /**
  6418. * Increments the number of references (ie. the number of Texture that point to it)
  6419. */
  6420. incrementReferences(): void;
  6421. /**
  6422. * Change the size of the texture (not the size of the content)
  6423. * @param width defines the new width
  6424. * @param height defines the new height
  6425. * @param depth defines the new depth (1 by default)
  6426. */
  6427. updateSize(width: int, height: int, depth?: int): void;
  6428. /** @hidden */ private _rebuild(): void;
  6429. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  6430. /**
  6431. * Dispose the current allocated resources
  6432. */
  6433. dispose(): void;
  6434. }
  6435. }
  6436. declare module BABYLON {
  6437. /**
  6438. * This represents the main contract an easing function should follow.
  6439. * Easing functions are used throughout the animation system.
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export interface IEasingFunction {
  6443. /**
  6444. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6445. * of the easing function.
  6446. * The link below provides some of the most common examples of easing functions.
  6447. * @see https://easings.net/
  6448. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6449. * @returns the corresponding value on the curve defined by the easing function
  6450. */
  6451. ease(gradient: number): number;
  6452. }
  6453. /**
  6454. * Base class used for every default easing function.
  6455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6456. */
  6457. export class EasingFunction implements IEasingFunction {
  6458. /**
  6459. * Interpolation follows the mathematical formula associated with the easing function.
  6460. */
  6461. static readonly EASINGMODE_EASEIN: number;
  6462. /**
  6463. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6464. */
  6465. static readonly EASINGMODE_EASEOUT: number;
  6466. /**
  6467. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6468. */
  6469. static readonly EASINGMODE_EASEINOUT: number;
  6470. private _easingMode;
  6471. /**
  6472. * Sets the easing mode of the current function.
  6473. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6474. */
  6475. setEasingMode(easingMode: number): void;
  6476. /**
  6477. * Gets the current easing mode.
  6478. * @returns the easing mode
  6479. */
  6480. getEasingMode(): number;
  6481. /**
  6482. * @hidden
  6483. */
  6484. easeInCore(gradient: number): number;
  6485. /**
  6486. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6487. * of the easing function.
  6488. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6489. * @returns the corresponding value on the curve defined by the easing function
  6490. */
  6491. ease(gradient: number): number;
  6492. }
  6493. /**
  6494. * Easing function with a circle shape (see link below).
  6495. * @see https://easings.net/#easeInCirc
  6496. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6497. */
  6498. export class CircleEase extends EasingFunction implements IEasingFunction {
  6499. /** @hidden */
  6500. easeInCore(gradient: number): number;
  6501. }
  6502. /**
  6503. * Easing function with a ease back shape (see link below).
  6504. * @see https://easings.net/#easeInBack
  6505. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6506. */
  6507. export class BackEase extends EasingFunction implements IEasingFunction {
  6508. /** Defines the amplitude of the function */
  6509. amplitude: number;
  6510. /**
  6511. * Instantiates a back ease easing
  6512. * @see https://easings.net/#easeInBack
  6513. * @param amplitude Defines the amplitude of the function
  6514. */
  6515. constructor(
  6516. /** Defines the amplitude of the function */
  6517. amplitude?: number);
  6518. /** @hidden */
  6519. easeInCore(gradient: number): number;
  6520. }
  6521. /**
  6522. * Easing function with a bouncing shape (see link below).
  6523. * @see https://easings.net/#easeInBounce
  6524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6525. */
  6526. export class BounceEase extends EasingFunction implements IEasingFunction {
  6527. /** Defines the number of bounces */
  6528. bounces: number;
  6529. /** Defines the amplitude of the bounce */
  6530. bounciness: number;
  6531. /**
  6532. * Instantiates a bounce easing
  6533. * @see https://easings.net/#easeInBounce
  6534. * @param bounces Defines the number of bounces
  6535. * @param bounciness Defines the amplitude of the bounce
  6536. */
  6537. constructor(
  6538. /** Defines the number of bounces */
  6539. bounces?: number,
  6540. /** Defines the amplitude of the bounce */
  6541. bounciness?: number);
  6542. /** @hidden */
  6543. easeInCore(gradient: number): number;
  6544. }
  6545. /**
  6546. * Easing function with a power of 3 shape (see link below).
  6547. * @see https://easings.net/#easeInCubic
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class CubicEase extends EasingFunction implements IEasingFunction {
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with an elastic shape (see link below).
  6556. * @see https://easings.net/#easeInElastic
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of oscillations*/
  6561. oscillations: number;
  6562. /** Defines the amplitude of the oscillations*/
  6563. springiness: number;
  6564. /**
  6565. * Instantiates an elastic easing function
  6566. * @see https://easings.net/#easeInElastic
  6567. * @param oscillations Defines the number of oscillations
  6568. * @param springiness Defines the amplitude of the oscillations
  6569. */
  6570. constructor(
  6571. /** Defines the number of oscillations*/
  6572. oscillations?: number,
  6573. /** Defines the amplitude of the oscillations*/
  6574. springiness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with an exponential shape (see link below).
  6580. * @see https://easings.net/#easeInExpo
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6584. /** Defines the exponent of the function */
  6585. exponent: number;
  6586. /**
  6587. * Instantiates an exponential easing function
  6588. * @see https://easings.net/#easeInExpo
  6589. * @param exponent Defines the exponent of the function
  6590. */
  6591. constructor(
  6592. /** Defines the exponent of the function */
  6593. exponent?: number);
  6594. /** @hidden */
  6595. easeInCore(gradient: number): number;
  6596. }
  6597. /**
  6598. * Easing function with a power shape (see link below).
  6599. * @see https://easings.net/#easeInQuad
  6600. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6601. */
  6602. export class PowerEase extends EasingFunction implements IEasingFunction {
  6603. /** Defines the power of the function */
  6604. power: number;
  6605. /**
  6606. * Instantiates an power base easing function
  6607. * @see https://easings.net/#easeInQuad
  6608. * @param power Defines the power of the function
  6609. */
  6610. constructor(
  6611. /** Defines the power of the function */
  6612. power?: number);
  6613. /** @hidden */
  6614. easeInCore(gradient: number): number;
  6615. }
  6616. /**
  6617. * Easing function with a power of 2 shape (see link below).
  6618. * @see https://easings.net/#easeInQuad
  6619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6620. */
  6621. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6622. /** @hidden */
  6623. easeInCore(gradient: number): number;
  6624. }
  6625. /**
  6626. * Easing function with a power of 4 shape (see link below).
  6627. * @see https://easings.net/#easeInQuart
  6628. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6629. */
  6630. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6631. /** @hidden */
  6632. easeInCore(gradient: number): number;
  6633. }
  6634. /**
  6635. * Easing function with a power of 5 shape (see link below).
  6636. * @see https://easings.net/#easeInQuint
  6637. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6638. */
  6639. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6640. /** @hidden */
  6641. easeInCore(gradient: number): number;
  6642. }
  6643. /**
  6644. * Easing function with a sin shape (see link below).
  6645. * @see https://easings.net/#easeInSine
  6646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6647. */
  6648. export class SineEase extends EasingFunction implements IEasingFunction {
  6649. /** @hidden */
  6650. easeInCore(gradient: number): number;
  6651. }
  6652. /**
  6653. * Easing function with a bezier shape (see link below).
  6654. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6656. */
  6657. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6658. /** Defines the x component of the start tangent in the bezier curve */
  6659. x1: number;
  6660. /** Defines the y component of the start tangent in the bezier curve */
  6661. y1: number;
  6662. /** Defines the x component of the end tangent in the bezier curve */
  6663. x2: number;
  6664. /** Defines the y component of the end tangent in the bezier curve */
  6665. y2: number;
  6666. /**
  6667. * Instantiates a bezier function
  6668. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6669. * @param x1 Defines the x component of the start tangent in the bezier curve
  6670. * @param y1 Defines the y component of the start tangent in the bezier curve
  6671. * @param x2 Defines the x component of the end tangent in the bezier curve
  6672. * @param y2 Defines the y component of the end tangent in the bezier curve
  6673. */
  6674. constructor(
  6675. /** Defines the x component of the start tangent in the bezier curve */
  6676. x1?: number,
  6677. /** Defines the y component of the start tangent in the bezier curve */
  6678. y1?: number,
  6679. /** Defines the x component of the end tangent in the bezier curve */
  6680. x2?: number,
  6681. /** Defines the y component of the end tangent in the bezier curve */
  6682. y2?: number);
  6683. /** @hidden */
  6684. easeInCore(gradient: number): number;
  6685. }
  6686. }
  6687. declare module BABYLON {
  6688. /**
  6689. * Defines an interface which represents an animation key frame
  6690. */
  6691. export interface IAnimationKey {
  6692. /**
  6693. * Frame of the key frame
  6694. */
  6695. frame: number;
  6696. /**
  6697. * Value at the specifies key frame
  6698. */
  6699. value: any;
  6700. /**
  6701. * The input tangent for the cubic hermite spline
  6702. */
  6703. inTangent?: any;
  6704. /**
  6705. * The output tangent for the cubic hermite spline
  6706. */
  6707. outTangent?: any;
  6708. /**
  6709. * The animation interpolation type
  6710. */
  6711. interpolation?: AnimationKeyInterpolation;
  6712. }
  6713. /**
  6714. * Enum for the animation key frame interpolation type
  6715. */
  6716. export enum AnimationKeyInterpolation {
  6717. /**
  6718. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6719. */
  6720. STEP = 1
  6721. }
  6722. }
  6723. declare module BABYLON {
  6724. /**
  6725. * Represents the range of an animation
  6726. */
  6727. export class AnimationRange {
  6728. /**The name of the animation range**/
  6729. name: string;
  6730. /**The starting frame of the animation */
  6731. from: number;
  6732. /**The ending frame of the animation*/
  6733. to: number;
  6734. /**
  6735. * Initializes the range of an animation
  6736. * @param name The name of the animation range
  6737. * @param from The starting frame of the animation
  6738. * @param to The ending frame of the animation
  6739. */
  6740. constructor(
  6741. /**The name of the animation range**/
  6742. name: string,
  6743. /**The starting frame of the animation */
  6744. from: number,
  6745. /**The ending frame of the animation*/
  6746. to: number);
  6747. /**
  6748. * Makes a copy of the animation range
  6749. * @returns A copy of the animation range
  6750. */
  6751. clone(): AnimationRange;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Composed of a frame, and an action function
  6757. */
  6758. export class AnimationEvent {
  6759. /** The frame for which the event is triggered **/
  6760. frame: number;
  6761. /** The event to perform when triggered **/
  6762. action: (currentFrame: number) => void;
  6763. /** Specifies if the event should be triggered only once**/
  6764. onlyOnce?: boolean | undefined;
  6765. /**
  6766. * Specifies if the animation event is done
  6767. */
  6768. isDone: boolean;
  6769. /**
  6770. * Initializes the animation event
  6771. * @param frame The frame for which the event is triggered
  6772. * @param action The event to perform when triggered
  6773. * @param onlyOnce Specifies if the event should be triggered only once
  6774. */
  6775. constructor(
  6776. /** The frame for which the event is triggered **/
  6777. frame: number,
  6778. /** The event to perform when triggered **/
  6779. action: (currentFrame: number) => void,
  6780. /** Specifies if the event should be triggered only once**/
  6781. onlyOnce?: boolean | undefined);
  6782. /** @hidden */ private _clone(): AnimationEvent;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /**
  6787. * Interface used to define a behavior
  6788. */
  6789. export interface Behavior<T> {
  6790. /** gets or sets behavior's name */
  6791. name: string;
  6792. /**
  6793. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6794. */
  6795. init(): void;
  6796. /**
  6797. * Called when the behavior is attached to a target
  6798. * @param target defines the target where the behavior is attached to
  6799. */
  6800. attach(target: T): void;
  6801. /**
  6802. * Called when the behavior is detached from its target
  6803. */
  6804. detach(): void;
  6805. }
  6806. /**
  6807. * Interface implemented by classes supporting behaviors
  6808. */
  6809. export interface IBehaviorAware<T> {
  6810. /**
  6811. * Attach a behavior
  6812. * @param behavior defines the behavior to attach
  6813. * @returns the current host
  6814. */
  6815. addBehavior(behavior: Behavior<T>): T;
  6816. /**
  6817. * Remove a behavior from the current object
  6818. * @param behavior defines the behavior to detach
  6819. * @returns the current host
  6820. */
  6821. removeBehavior(behavior: Behavior<T>): T;
  6822. /**
  6823. * Gets a behavior using its name to search
  6824. * @param name defines the name to search
  6825. * @returns the behavior or null if not found
  6826. */
  6827. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * @hidden
  6833. */
  6834. export class IntersectionInfo {
  6835. bu: Nullable<number>;
  6836. bv: Nullable<number>;
  6837. distance: number;
  6838. faceId: number;
  6839. subMeshId: number;
  6840. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6841. }
  6842. }
  6843. declare module BABYLON {
  6844. /**
  6845. * Class used to store bounding sphere information
  6846. */
  6847. export class BoundingSphere {
  6848. /**
  6849. * Gets the center of the bounding sphere in local space
  6850. */
  6851. readonly center: Vector3;
  6852. /**
  6853. * Radius of the bounding sphere in local space
  6854. */
  6855. radius: number;
  6856. /**
  6857. * Gets the center of the bounding sphere in world space
  6858. */
  6859. readonly centerWorld: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in world space
  6862. */
  6863. radiusWorld: number;
  6864. /**
  6865. * Gets the minimum vector in local space
  6866. */
  6867. readonly minimum: Vector3;
  6868. /**
  6869. * Gets the maximum vector in local space
  6870. */
  6871. readonly maximum: Vector3;
  6872. private _worldMatrix;
  6873. private static readonly TmpVector3;
  6874. /**
  6875. * Creates a new bounding sphere
  6876. * @param min defines the minimum vector (in local space)
  6877. * @param max defines the maximum vector (in local space)
  6878. * @param worldMatrix defines the new world matrix
  6879. */
  6880. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6881. /**
  6882. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6883. * @param min defines the new minimum vector (in local space)
  6884. * @param max defines the new maximum vector (in local space)
  6885. * @param worldMatrix defines the new world matrix
  6886. */
  6887. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Scale the current bounding sphere by applying a scale factor
  6890. * @param factor defines the scale factor to apply
  6891. * @returns the current bounding box
  6892. */
  6893. scale(factor: number): BoundingSphere;
  6894. /**
  6895. * Gets the world matrix of the bounding box
  6896. * @returns a matrix
  6897. */
  6898. getWorldMatrix(): DeepImmutable<Matrix>;
  6899. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * Tests if the bounding sphere is intersecting the frustum planes
  6902. * @param frustumPlanes defines the frustum planes to test
  6903. * @returns true if there is an intersection
  6904. */
  6905. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6906. /**
  6907. * Tests if the bounding sphere center is in between the frustum planes.
  6908. * Used for optimistic fast inclusion.
  6909. * @param frustumPlanes defines the frustum planes to test
  6910. * @returns true if the sphere center is in between the frustum planes
  6911. */
  6912. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6913. /**
  6914. * Tests if a point is inside the bounding sphere
  6915. * @param point defines the point to test
  6916. * @returns true if the point is inside the bounding sphere
  6917. */
  6918. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6919. /**
  6920. * Checks if two sphere intersct
  6921. * @param sphere0 sphere 0
  6922. * @param sphere1 sphere 1
  6923. * @returns true if the speres intersect
  6924. */
  6925. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6926. }
  6927. }
  6928. declare module BABYLON {
  6929. /**
  6930. * Class used to store bounding box information
  6931. */
  6932. export class BoundingBox implements ICullable {
  6933. /**
  6934. * Gets the 8 vectors representing the bounding box in local space
  6935. */
  6936. readonly vectors: Vector3[];
  6937. /**
  6938. * Gets the center of the bounding box in local space
  6939. */
  6940. readonly center: Vector3;
  6941. /**
  6942. * Gets the center of the bounding box in world space
  6943. */
  6944. readonly centerWorld: Vector3;
  6945. /**
  6946. * Gets the extend size in local space
  6947. */
  6948. readonly extendSize: Vector3;
  6949. /**
  6950. * Gets the extend size in world space
  6951. */
  6952. readonly extendSizeWorld: Vector3;
  6953. /**
  6954. * Gets the OBB (object bounding box) directions
  6955. */
  6956. readonly directions: Vector3[];
  6957. /**
  6958. * Gets the 8 vectors representing the bounding box in world space
  6959. */
  6960. readonly vectorsWorld: Vector3[];
  6961. /**
  6962. * Gets the minimum vector in world space
  6963. */
  6964. readonly minimumWorld: Vector3;
  6965. /**
  6966. * Gets the maximum vector in world space
  6967. */
  6968. readonly maximumWorld: Vector3;
  6969. /**
  6970. * Gets the minimum vector in local space
  6971. */
  6972. readonly minimum: Vector3;
  6973. /**
  6974. * Gets the maximum vector in local space
  6975. */
  6976. readonly maximum: Vector3;
  6977. private _worldMatrix;
  6978. private static readonly TmpVector3;
  6979. /**
  6980. * @hidden
  6981. */ private _tag: number;
  6982. /**
  6983. * Creates a new bounding box
  6984. * @param min defines the minimum vector (in local space)
  6985. * @param max defines the maximum vector (in local space)
  6986. * @param worldMatrix defines the new world matrix
  6987. */
  6988. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6989. /**
  6990. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6991. * @param min defines the new minimum vector (in local space)
  6992. * @param max defines the new maximum vector (in local space)
  6993. * @param worldMatrix defines the new world matrix
  6994. */
  6995. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Scale the current bounding box by applying a scale factor
  6998. * @param factor defines the scale factor to apply
  6999. * @returns the current bounding box
  7000. */
  7001. scale(factor: number): BoundingBox;
  7002. /**
  7003. * Gets the world matrix of the bounding box
  7004. * @returns a matrix
  7005. */
  7006. getWorldMatrix(): DeepImmutable<Matrix>;
  7007. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  7008. /**
  7009. * Tests if the bounding box is intersecting the frustum planes
  7010. * @param frustumPlanes defines the frustum planes to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7014. /**
  7015. * Tests if the bounding box is entirely inside the frustum planes
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @returns true if there is an inclusion
  7018. */
  7019. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. /**
  7021. * Tests if a point is inside the bounding box
  7022. * @param point defines the point to test
  7023. * @returns true if the point is inside the bounding box
  7024. */
  7025. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7026. /**
  7027. * Tests if the bounding box intersects with a bounding sphere
  7028. * @param sphere defines the sphere to test
  7029. * @returns true if there is an intersection
  7030. */
  7031. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7032. /**
  7033. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7034. * @param min defines the min vector to use
  7035. * @param max defines the max vector to use
  7036. * @returns true if there is an intersection
  7037. */
  7038. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7039. /**
  7040. * Tests if two bounding boxes are intersections
  7041. * @param box0 defines the first box to test
  7042. * @param box1 defines the second box to test
  7043. * @returns true if there is an intersection
  7044. */
  7045. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7046. /**
  7047. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7048. * @param minPoint defines the minimum vector of the bounding box
  7049. * @param maxPoint defines the maximum vector of the bounding box
  7050. * @param sphereCenter defines the sphere center
  7051. * @param sphereRadius defines the sphere radius
  7052. * @returns true if there is an intersection
  7053. */
  7054. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7055. /**
  7056. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7057. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7058. * @param frustumPlanes defines the frustum planes to test
  7059. * @return true if there is an inclusion
  7060. */
  7061. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /**
  7063. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7064. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7065. * @param frustumPlanes defines the frustum planes to test
  7066. * @return true if there is an intersection
  7067. */
  7068. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7069. }
  7070. }
  7071. declare module BABYLON {
  7072. /** @hidden */
  7073. export class Collider {
  7074. /** Define if a collision was found */
  7075. collisionFound: boolean;
  7076. /**
  7077. * Define last intersection point in local space
  7078. */
  7079. intersectionPoint: Vector3;
  7080. /**
  7081. * Define last collided mesh
  7082. */
  7083. collidedMesh: Nullable<AbstractMesh>;
  7084. private _collisionPoint;
  7085. private _planeIntersectionPoint;
  7086. private _tempVector;
  7087. private _tempVector2;
  7088. private _tempVector3;
  7089. private _tempVector4;
  7090. private _edge;
  7091. private _baseToVertex;
  7092. private _destinationPoint;
  7093. private _slidePlaneNormal;
  7094. private _displacementVector;
  7095. /** @hidden */ private _radius: Vector3;
  7096. /** @hidden */ private _retry: number;
  7097. private _velocity;
  7098. private _basePoint;
  7099. private _epsilon;
  7100. /** @hidden */ private _velocityWorldLength: number;
  7101. /** @hidden */ private _basePointWorld: Vector3;
  7102. private _velocityWorld;
  7103. private _normalizedVelocity;
  7104. /** @hidden */ private _initialVelocity: Vector3;
  7105. /** @hidden */ private _initialPosition: Vector3;
  7106. private _nearestDistance;
  7107. private _collisionMask;
  7108. collisionMask: number;
  7109. /**
  7110. * Gets the plane normal used to compute the sliding response (in local space)
  7111. */
  7112. readonly slidePlaneNormal: Vector3;
  7113. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7114. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7115. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7117. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7118. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7119. }
  7120. }
  7121. declare module BABYLON {
  7122. /**
  7123. * Interface for cullable objects
  7124. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7125. */
  7126. export interface ICullable {
  7127. /**
  7128. * Checks if the object or part of the object is in the frustum
  7129. * @param frustumPlanes Camera near/planes
  7130. * @returns true if the object is in frustum otherwise false
  7131. */
  7132. isInFrustum(frustumPlanes: Plane[]): boolean;
  7133. /**
  7134. * Checks if a cullable object (mesh...) is in the camera frustum
  7135. * Unlike isInFrustum this cheks the full bounding box
  7136. * @param frustumPlanes Camera near/planes
  7137. * @returns true if the object is in frustum otherwise false
  7138. */
  7139. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7140. }
  7141. /**
  7142. * Info for a bounding data of a mesh
  7143. */
  7144. export class BoundingInfo implements ICullable {
  7145. /**
  7146. * Bounding box for the mesh
  7147. */
  7148. readonly boundingBox: BoundingBox;
  7149. /**
  7150. * Bounding sphere for the mesh
  7151. */
  7152. readonly boundingSphere: BoundingSphere;
  7153. private _isLocked;
  7154. private static readonly TmpVector3;
  7155. /**
  7156. * Constructs bounding info
  7157. * @param minimum min vector of the bounding box/sphere
  7158. * @param maximum max vector of the bounding box/sphere
  7159. * @param worldMatrix defines the new world matrix
  7160. */
  7161. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7162. /**
  7163. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7164. * @param min defines the new minimum vector (in local space)
  7165. * @param max defines the new maximum vector (in local space)
  7166. * @param worldMatrix defines the new world matrix
  7167. */
  7168. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * min vector of the bounding box/sphere
  7171. */
  7172. readonly minimum: Vector3;
  7173. /**
  7174. * max vector of the bounding box/sphere
  7175. */
  7176. readonly maximum: Vector3;
  7177. /**
  7178. * If the info is locked and won't be updated to avoid perf overhead
  7179. */
  7180. isLocked: boolean;
  7181. /**
  7182. * Updates the bounding sphere and box
  7183. * @param world world matrix to be used to update
  7184. */
  7185. update(world: DeepImmutable<Matrix>): void;
  7186. /**
  7187. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7188. * @param center New center of the bounding info
  7189. * @param extend New extend of the bounding info
  7190. * @returns the current bounding info
  7191. */
  7192. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7193. /**
  7194. * Scale the current bounding info by applying a scale factor
  7195. * @param factor defines the scale factor to apply
  7196. * @returns the current bounding info
  7197. */
  7198. scale(factor: number): BoundingInfo;
  7199. /**
  7200. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7201. * @param frustumPlanes defines the frustum to test
  7202. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7203. * @returns true if the bounding info is in the frustum planes
  7204. */
  7205. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7206. /**
  7207. * Gets the world distance between the min and max points of the bounding box
  7208. */
  7209. readonly diagonalLength: number;
  7210. /**
  7211. * Checks if a cullable object (mesh...) is in the camera frustum
  7212. * Unlike isInFrustum this cheks the full bounding box
  7213. * @param frustumPlanes Camera near/planes
  7214. * @returns true if the object is in frustum otherwise false
  7215. */
  7216. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7217. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Defines an array and its length.
  7238. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7239. */
  7240. export interface ISmartArrayLike<T> {
  7241. /**
  7242. * The data of the array.
  7243. */
  7244. data: Array<T>;
  7245. /**
  7246. * The active length of the array.
  7247. */
  7248. length: number;
  7249. }
  7250. /**
  7251. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7252. */
  7253. export class SmartArray<T> implements ISmartArrayLike<T> {
  7254. /**
  7255. * The full set of data from the array.
  7256. */
  7257. data: Array<T>;
  7258. /**
  7259. * The active length of the array.
  7260. */
  7261. length: number;
  7262. protected _id: number;
  7263. /**
  7264. * Instantiates a Smart Array.
  7265. * @param capacity defines the default capacity of the array.
  7266. */
  7267. constructor(capacity: number);
  7268. /**
  7269. * Pushes a value at the end of the active data.
  7270. * @param value defines the object to push in the array.
  7271. */
  7272. push(value: T): void;
  7273. /**
  7274. * Iterates over the active data and apply the lambda to them.
  7275. * @param func defines the action to apply on each value.
  7276. */
  7277. forEach(func: (content: T) => void): void;
  7278. /**
  7279. * Sorts the full sets of data.
  7280. * @param compareFn defines the comparison function to apply.
  7281. */
  7282. sort(compareFn: (a: T, b: T) => number): void;
  7283. /**
  7284. * Resets the active data to an empty array.
  7285. */
  7286. reset(): void;
  7287. /**
  7288. * Releases all the data from the array as well as the array.
  7289. */
  7290. dispose(): void;
  7291. /**
  7292. * Concats the active data with a given array.
  7293. * @param array defines the data to concatenate with.
  7294. */
  7295. concat(array: any): void;
  7296. /**
  7297. * Returns the position of a value in the active data.
  7298. * @param value defines the value to find the index for
  7299. * @returns the index if found in the active data otherwise -1
  7300. */
  7301. indexOf(value: T): number;
  7302. /**
  7303. * Returns whether an element is part of the active data.
  7304. * @param value defines the value to look for
  7305. * @returns true if found in the active data otherwise false
  7306. */
  7307. contains(value: T): boolean;
  7308. private static _GlobalId;
  7309. }
  7310. /**
  7311. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7312. * The data in this array can only be present once
  7313. */
  7314. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7315. private _duplicateId;
  7316. /**
  7317. * Pushes a value at the end of the active data.
  7318. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7319. * @param value defines the object to push in the array.
  7320. */
  7321. push(value: T): void;
  7322. /**
  7323. * Pushes a value at the end of the active data.
  7324. * If the data is already present, it won t be added again
  7325. * @param value defines the object to push in the array.
  7326. * @returns true if added false if it was already present
  7327. */
  7328. pushNoDuplicate(value: T): boolean;
  7329. /**
  7330. * Resets the active data to an empty array.
  7331. */
  7332. reset(): void;
  7333. /**
  7334. * Concats the active data with a given array.
  7335. * This ensures no dupplicate will be present in the result.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concatWithNoDuplicate(array: any): void;
  7339. }
  7340. }
  7341. declare module BABYLON {
  7342. /**
  7343. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7344. * separate meshes. This can be use to improve performances.
  7345. * @see http://doc.babylonjs.com/how_to/multi_materials
  7346. */
  7347. export class MultiMaterial extends Material {
  7348. private _subMaterials;
  7349. /**
  7350. * Gets or Sets the list of Materials used within the multi material.
  7351. * They need to be ordered according to the submeshes order in the associated mesh
  7352. */
  7353. subMaterials: Nullable<Material>[];
  7354. /**
  7355. * Function used to align with Node.getChildren()
  7356. * @returns the list of Materials used within the multi material
  7357. */
  7358. getChildren(): Nullable<Material>[];
  7359. /**
  7360. * Instantiates a new Multi Material
  7361. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7362. * separate meshes. This can be use to improve performances.
  7363. * @see http://doc.babylonjs.com/how_to/multi_materials
  7364. * @param name Define the name in the scene
  7365. * @param scene Define the scene the material belongs to
  7366. */
  7367. constructor(name: string, scene: Scene);
  7368. private _hookArray;
  7369. /**
  7370. * Get one of the submaterial by its index in the submaterials array
  7371. * @param index The index to look the sub material at
  7372. * @returns The Material if the index has been defined
  7373. */
  7374. getSubMaterial(index: number): Nullable<Material>;
  7375. /**
  7376. * Get the list of active textures for the whole sub materials list.
  7377. * @returns All the textures that will be used during the rendering
  7378. */
  7379. getActiveTextures(): BaseTexture[];
  7380. /**
  7381. * Gets the current class name of the material e.g. "MultiMaterial"
  7382. * Mainly use in serialization.
  7383. * @returns the class name
  7384. */
  7385. getClassName(): string;
  7386. /**
  7387. * Checks if the material is ready to render the requested sub mesh
  7388. * @param mesh Define the mesh the submesh belongs to
  7389. * @param subMesh Define the sub mesh to look readyness for
  7390. * @param useInstances Define whether or not the material is used with instances
  7391. * @returns true if ready, otherwise false
  7392. */
  7393. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7394. /**
  7395. * Clones the current material and its related sub materials
  7396. * @param name Define the name of the newly cloned material
  7397. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7398. * @returns the cloned material
  7399. */
  7400. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7401. /**
  7402. * Serializes the materials into a JSON representation.
  7403. * @returns the JSON representation
  7404. */
  7405. serialize(): any;
  7406. /**
  7407. * Dispose the material and release its associated resources
  7408. * @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)
  7409. * @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)
  7410. * @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)
  7411. */
  7412. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7413. /**
  7414. * Creates a MultiMaterial from parsed MultiMaterial data.
  7415. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7416. * @param scene defines the hosting scene
  7417. * @returns a new MultiMaterial
  7418. */
  7419. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7420. }
  7421. }
  7422. declare module BABYLON {
  7423. /**
  7424. * Class used to represent data loading progression
  7425. */
  7426. export class SceneLoaderFlags {
  7427. private static _ForceFullSceneLoadingForIncremental;
  7428. private static _ShowLoadingScreen;
  7429. private static _CleanBoneMatrixWeights;
  7430. private static _loggingLevel;
  7431. /**
  7432. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7433. */
  7434. static ForceFullSceneLoadingForIncremental: boolean;
  7435. /**
  7436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7437. */
  7438. static ShowLoadingScreen: boolean;
  7439. /**
  7440. * Defines the current logging level (while loading the scene)
  7441. * @ignorenaming
  7442. */
  7443. static loggingLevel: number;
  7444. /**
  7445. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7446. */
  7447. static CleanBoneMatrixWeights: boolean;
  7448. }
  7449. }
  7450. declare module BABYLON {
  7451. /**
  7452. * 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.
  7453. * @see https://doc.babylonjs.com/how_to/transformnode
  7454. */
  7455. export class TransformNode extends Node {
  7456. /**
  7457. * Object will not rotate to face the camera
  7458. */
  7459. static BILLBOARDMODE_NONE: number;
  7460. /**
  7461. * Object will rotate to face the camera but only on the x axis
  7462. */
  7463. static BILLBOARDMODE_X: number;
  7464. /**
  7465. * Object will rotate to face the camera but only on the y axis
  7466. */
  7467. static BILLBOARDMODE_Y: number;
  7468. /**
  7469. * Object will rotate to face the camera but only on the z axis
  7470. */
  7471. static BILLBOARDMODE_Z: number;
  7472. /**
  7473. * Object will rotate to face the camera
  7474. */
  7475. static BILLBOARDMODE_ALL: number;
  7476. private _forward;
  7477. private _forwardInverted;
  7478. private _up;
  7479. private _right;
  7480. private _rightInverted;
  7481. private _position;
  7482. private _rotation;
  7483. private _rotationQuaternion;
  7484. protected _scaling: Vector3;
  7485. protected _isDirty: boolean;
  7486. private _transformToBoneReferal;
  7487. private _billboardMode;
  7488. /**
  7489. * Gets or sets the billboard mode. Default is 0.
  7490. *
  7491. * | Value | Type | Description |
  7492. * | --- | --- | --- |
  7493. * | 0 | BILLBOARDMODE_NONE | |
  7494. * | 1 | BILLBOARDMODE_X | |
  7495. * | 2 | BILLBOARDMODE_Y | |
  7496. * | 4 | BILLBOARDMODE_Z | |
  7497. * | 7 | BILLBOARDMODE_ALL | |
  7498. *
  7499. */
  7500. billboardMode: number;
  7501. private _preserveParentRotationForBillboard;
  7502. /**
  7503. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7504. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7505. */
  7506. preserveParentRotationForBillboard: boolean;
  7507. /**
  7508. * 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
  7509. */
  7510. scalingDeterminant: number;
  7511. private _infiniteDistance;
  7512. /**
  7513. * Gets or sets the distance of the object to max, often used by skybox
  7514. */
  7515. infiniteDistance: boolean;
  7516. /**
  7517. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7518. * By default the system will update normals to compensate
  7519. */
  7520. ignoreNonUniformScaling: boolean;
  7521. /**
  7522. * 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
  7523. */
  7524. reIntegrateRotationIntoRotationQuaternion: boolean;
  7525. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  7526. /** @hidden */ private _localMatrix: Matrix;
  7527. private _usePivotMatrix;
  7528. private _absolutePosition;
  7529. private _pivotMatrix;
  7530. private _pivotMatrixInverse;
  7531. protected _postMultiplyPivotMatrix: boolean;
  7532. protected _isWorldMatrixFrozen: boolean;
  7533. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  7534. /**
  7535. * An event triggered after the world matrix is updated
  7536. */
  7537. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7538. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7539. /**
  7540. * Gets a string identifying the name of the class
  7541. * @returns "TransformNode" string
  7542. */
  7543. getClassName(): string;
  7544. /**
  7545. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7546. */
  7547. position: Vector3;
  7548. /**
  7549. * 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)).
  7550. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7551. */
  7552. rotation: Vector3;
  7553. /**
  7554. * 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)).
  7555. */
  7556. scaling: Vector3;
  7557. /**
  7558. * 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).
  7559. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7560. */
  7561. rotationQuaternion: Nullable<Quaternion>;
  7562. /**
  7563. * The forward direction of that transform in world space.
  7564. */
  7565. readonly forward: Vector3;
  7566. /**
  7567. * The up direction of that transform in world space.
  7568. */
  7569. readonly up: Vector3;
  7570. /**
  7571. * The right direction of that transform in world space.
  7572. */
  7573. readonly right: Vector3;
  7574. /**
  7575. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7576. * @param matrix the matrix to copy the pose from
  7577. * @returns this TransformNode.
  7578. */
  7579. updatePoseMatrix(matrix: Matrix): TransformNode;
  7580. /**
  7581. * Returns the mesh Pose matrix.
  7582. * @returns the pose matrix
  7583. */
  7584. getPoseMatrix(): Matrix;
  7585. /** @hidden */ private _isSynchronized(): boolean;
  7586. /** @hidden */ private _initCache(): void;
  7587. /**
  7588. * Flag the transform node as dirty (Forcing it to update everything)
  7589. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7590. * @returns this transform node
  7591. */
  7592. markAsDirty(property: string): TransformNode;
  7593. /**
  7594. * Returns the current mesh absolute position.
  7595. * Returns a Vector3.
  7596. */
  7597. readonly absolutePosition: Vector3;
  7598. /**
  7599. * Sets a new matrix to apply before all other transformation
  7600. * @param matrix defines the transform matrix
  7601. * @returns the current TransformNode
  7602. */
  7603. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7604. /**
  7605. * Sets a new pivot matrix to the current node
  7606. * @param matrix defines the new pivot matrix to use
  7607. * @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
  7608. * @returns the current TransformNode
  7609. */
  7610. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7611. /**
  7612. * Returns the mesh pivot matrix.
  7613. * Default : Identity.
  7614. * @returns the matrix
  7615. */
  7616. getPivotMatrix(): Matrix;
  7617. /**
  7618. * Prevents the World matrix to be computed any longer.
  7619. * @returns the TransformNode.
  7620. */
  7621. freezeWorldMatrix(): TransformNode;
  7622. /**
  7623. * Allows back the World matrix computation.
  7624. * @returns the TransformNode.
  7625. */
  7626. unfreezeWorldMatrix(): this;
  7627. /**
  7628. * True if the World matrix has been frozen.
  7629. */
  7630. readonly isWorldMatrixFrozen: boolean;
  7631. /**
  7632. * Retuns the mesh absolute position in the World.
  7633. * @returns a Vector3.
  7634. */
  7635. getAbsolutePosition(): Vector3;
  7636. /**
  7637. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7638. * @param absolutePosition the absolute position to set
  7639. * @returns the TransformNode.
  7640. */
  7641. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7642. /**
  7643. * Sets the mesh position in its local space.
  7644. * @param vector3 the position to set in localspace
  7645. * @returns the TransformNode.
  7646. */
  7647. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7648. /**
  7649. * Returns the mesh position in the local space from the current World matrix values.
  7650. * @returns a new Vector3.
  7651. */
  7652. getPositionExpressedInLocalSpace(): Vector3;
  7653. /**
  7654. * Translates the mesh along the passed Vector3 in its local space.
  7655. * @param vector3 the distance to translate in localspace
  7656. * @returns the TransformNode.
  7657. */
  7658. locallyTranslate(vector3: Vector3): TransformNode;
  7659. private static _lookAtVectorCache;
  7660. /**
  7661. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7662. * @param targetPoint the position (must be in same space as current mesh) to look at
  7663. * @param yawCor optional yaw (y-axis) correction in radians
  7664. * @param pitchCor optional pitch (x-axis) correction in radians
  7665. * @param rollCor optional roll (z-axis) correction in radians
  7666. * @param space the choosen space of the target
  7667. * @returns the TransformNode.
  7668. */
  7669. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7670. /**
  7671. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7672. * This Vector3 is expressed in the World space.
  7673. * @param localAxis axis to rotate
  7674. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7675. */
  7676. getDirection(localAxis: Vector3): Vector3;
  7677. /**
  7678. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7679. * localAxis is expressed in the mesh local space.
  7680. * result is computed in the Wordl space from the mesh World matrix.
  7681. * @param localAxis axis to rotate
  7682. * @param result the resulting transformnode
  7683. * @returns this TransformNode.
  7684. */
  7685. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7686. /**
  7687. * Sets this transform node rotation to the given local axis.
  7688. * @param localAxis the axis in local space
  7689. * @param yawCor optional yaw (y-axis) correction in radians
  7690. * @param pitchCor optional pitch (x-axis) correction in radians
  7691. * @param rollCor optional roll (z-axis) correction in radians
  7692. * @returns this TransformNode
  7693. */
  7694. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7695. /**
  7696. * Sets a new pivot point to the current node
  7697. * @param point defines the new pivot point to use
  7698. * @param space defines if the point is in world or local space (local by default)
  7699. * @returns the current TransformNode
  7700. */
  7701. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7702. /**
  7703. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7704. * @returns the pivot point
  7705. */
  7706. getPivotPoint(): Vector3;
  7707. /**
  7708. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7709. * @param result the vector3 to store the result
  7710. * @returns this TransformNode.
  7711. */
  7712. getPivotPointToRef(result: Vector3): TransformNode;
  7713. /**
  7714. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7715. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7716. */
  7717. getAbsolutePivotPoint(): Vector3;
  7718. /**
  7719. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7720. * @param result vector3 to store the result
  7721. * @returns this TransformNode.
  7722. */
  7723. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7724. /**
  7725. * Defines the passed node as the parent of the current node.
  7726. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7727. * @see https://doc.babylonjs.com/how_to/parenting
  7728. * @param node the node ot set as the parent
  7729. * @returns this TransformNode.
  7730. */
  7731. setParent(node: Nullable<Node>): TransformNode;
  7732. private _nonUniformScaling;
  7733. /**
  7734. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7735. */
  7736. readonly nonUniformScaling: boolean;
  7737. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  7738. /**
  7739. * Attach the current TransformNode to another TransformNode associated with a bone
  7740. * @param bone Bone affecting the TransformNode
  7741. * @param affectedTransformNode TransformNode associated with the bone
  7742. * @returns this object
  7743. */
  7744. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7745. /**
  7746. * Detach the transform node if its associated with a bone
  7747. * @returns this object
  7748. */
  7749. detachFromBone(): TransformNode;
  7750. private static _rotationAxisCache;
  7751. /**
  7752. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7753. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7754. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7755. * The passed axis is also normalized.
  7756. * @param axis the axis to rotate around
  7757. * @param amount the amount to rotate in radians
  7758. * @param space Space to rotate in (Default: local)
  7759. * @returns the TransformNode.
  7760. */
  7761. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7762. /**
  7763. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7764. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7765. * The passed axis is also normalized. .
  7766. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7767. * @param point the point to rotate around
  7768. * @param axis the axis to rotate around
  7769. * @param amount the amount to rotate in radians
  7770. * @returns the TransformNode
  7771. */
  7772. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7773. /**
  7774. * Translates the mesh along the axis vector for the passed distance in the given space.
  7775. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7776. * @param axis the axis to translate in
  7777. * @param distance the distance to translate
  7778. * @param space Space to rotate in (Default: local)
  7779. * @returns the TransformNode.
  7780. */
  7781. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7782. /**
  7783. * Adds a rotation step to the mesh current rotation.
  7784. * x, y, z are Euler angles expressed in radians.
  7785. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7786. * This means this rotation is made in the mesh local space only.
  7787. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7788. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7789. * ```javascript
  7790. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7791. * ```
  7792. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7793. * 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.
  7794. * @param x Rotation to add
  7795. * @param y Rotation to add
  7796. * @param z Rotation to add
  7797. * @returns the TransformNode.
  7798. */
  7799. addRotation(x: number, y: number, z: number): TransformNode;
  7800. /**
  7801. * @hidden
  7802. */
  7803. protected _getEffectiveParent(): Nullable<Node>;
  7804. /**
  7805. * Computes the world matrix of the node
  7806. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7807. * @returns the world matrix
  7808. */
  7809. computeWorldMatrix(force?: boolean): Matrix;
  7810. protected _afterComputeWorldMatrix(): void;
  7811. /**
  7812. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7813. * @param func callback function to add
  7814. *
  7815. * @returns the TransformNode.
  7816. */
  7817. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7818. /**
  7819. * Removes a registered callback function.
  7820. * @param func callback function to remove
  7821. * @returns the TransformNode.
  7822. */
  7823. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7824. /**
  7825. * Gets the position of the current mesh in camera space
  7826. * @param camera defines the camera to use
  7827. * @returns a position
  7828. */
  7829. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7830. /**
  7831. * Returns the distance from the mesh to the active camera
  7832. * @param camera defines the camera to use
  7833. * @returns the distance
  7834. */
  7835. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7836. /**
  7837. * Clone the current transform node
  7838. * @param name Name of the new clone
  7839. * @param newParent New parent for the clone
  7840. * @param doNotCloneChildren Do not clone children hierarchy
  7841. * @returns the new transform node
  7842. */
  7843. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7844. /**
  7845. * Serializes the objects information.
  7846. * @param currentSerializationObject defines the object to serialize in
  7847. * @returns the serialized object
  7848. */
  7849. serialize(currentSerializationObject?: any): any;
  7850. /**
  7851. * Returns a new TransformNode object parsed from the source provided.
  7852. * @param parsedTransformNode is the source.
  7853. * @param scene the scne the object belongs to
  7854. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7855. * @returns a new TransformNode object parsed from the source provided.
  7856. */
  7857. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7858. /**
  7859. * Get all child-transformNodes of this node
  7860. * @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
  7861. * @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
  7862. * @returns an array of TransformNode
  7863. */
  7864. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7865. /**
  7866. * Releases resources associated with this transform node.
  7867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7869. */
  7870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7871. }
  7872. }
  7873. declare module BABYLON {
  7874. /**
  7875. * Class used to override all child animations of a given target
  7876. */
  7877. export class AnimationPropertiesOverride {
  7878. /**
  7879. * Gets or sets a value indicating if animation blending must be used
  7880. */
  7881. enableBlending: boolean;
  7882. /**
  7883. * Gets or sets the blending speed to use when enableBlending is true
  7884. */
  7885. blendingSpeed: number;
  7886. /**
  7887. * Gets or sets the default loop mode to use
  7888. */
  7889. loopMode: number;
  7890. }
  7891. }
  7892. declare module BABYLON {
  7893. /**
  7894. * Class used to store bone information
  7895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7896. */
  7897. export class Bone extends Node {
  7898. /**
  7899. * defines the bone name
  7900. */
  7901. name: string;
  7902. private static _tmpVecs;
  7903. private static _tmpQuat;
  7904. private static _tmpMats;
  7905. /**
  7906. * Gets the list of child bones
  7907. */
  7908. children: Bone[];
  7909. /** Gets the animations associated with this bone */
  7910. animations: Animation[];
  7911. /**
  7912. * Gets or sets bone length
  7913. */
  7914. length: number;
  7915. /**
  7916. * @hidden Internal only
  7917. * Set this value to map this bone to a different index in the transform matrices
  7918. * Set this value to -1 to exclude the bone from the transform matrices
  7919. */ private _index: Nullable<number>;
  7920. private _skeleton;
  7921. private _localMatrix;
  7922. private _restPose;
  7923. private _baseMatrix;
  7924. private _absoluteTransform;
  7925. private _invertedAbsoluteTransform;
  7926. private _parent;
  7927. private _scalingDeterminant;
  7928. private _worldTransform;
  7929. private _localScaling;
  7930. private _localRotation;
  7931. private _localPosition;
  7932. private _needToDecompose;
  7933. private _needToCompose;
  7934. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  7935. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  7936. /** @hidden */
  7937. /** @hidden */ private _matrix: Matrix;
  7938. /**
  7939. * Create a new bone
  7940. * @param name defines the bone name
  7941. * @param skeleton defines the parent skeleton
  7942. * @param parentBone defines the parent (can be null if the bone is the root)
  7943. * @param localMatrix defines the local matrix
  7944. * @param restPose defines the rest pose matrix
  7945. * @param baseMatrix defines the base matrix
  7946. * @param index defines index of the bone in the hiearchy
  7947. */
  7948. constructor(
  7949. /**
  7950. * defines the bone name
  7951. */
  7952. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7953. /**
  7954. * Gets the current object class name.
  7955. * @return the class name
  7956. */
  7957. getClassName(): string;
  7958. /**
  7959. * Gets the parent skeleton
  7960. * @returns a skeleton
  7961. */
  7962. getSkeleton(): Skeleton;
  7963. /**
  7964. * Gets parent bone
  7965. * @returns a bone or null if the bone is the root of the bone hierarchy
  7966. */
  7967. getParent(): Nullable<Bone>;
  7968. /**
  7969. * Returns an array containing the root bones
  7970. * @returns an array containing the root bones
  7971. */
  7972. getChildren(): Array<Bone>;
  7973. /**
  7974. * Sets the parent bone
  7975. * @param parent defines the parent (can be null if the bone is the root)
  7976. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7977. */
  7978. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7979. /**
  7980. * Gets the local matrix
  7981. * @returns a matrix
  7982. */
  7983. getLocalMatrix(): Matrix;
  7984. /**
  7985. * Gets the base matrix (initial matrix which remains unchanged)
  7986. * @returns a matrix
  7987. */
  7988. getBaseMatrix(): Matrix;
  7989. /**
  7990. * Gets the rest pose matrix
  7991. * @returns a matrix
  7992. */
  7993. getRestPose(): Matrix;
  7994. /**
  7995. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7996. */
  7997. getWorldMatrix(): Matrix;
  7998. /**
  7999. * Sets the local matrix to rest pose matrix
  8000. */
  8001. returnToRest(): void;
  8002. /**
  8003. * Gets the inverse of the absolute transform matrix.
  8004. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8005. * @returns a matrix
  8006. */
  8007. getInvertedAbsoluteTransform(): Matrix;
  8008. /**
  8009. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8010. * @returns a matrix
  8011. */
  8012. getAbsoluteTransform(): Matrix;
  8013. /**
  8014. * Links with the given transform node.
  8015. * The local matrix of this bone is copied from the transform node every frame.
  8016. * @param transformNode defines the transform node to link to
  8017. */
  8018. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8019. /** Gets or sets current position (in local space) */
  8020. position: Vector3;
  8021. /** Gets or sets current rotation (in local space) */
  8022. rotation: Vector3;
  8023. /** Gets or sets current rotation quaternion (in local space) */
  8024. rotationQuaternion: Quaternion;
  8025. /** Gets or sets current scaling (in local space) */
  8026. scaling: Vector3;
  8027. /**
  8028. * Gets the animation properties override
  8029. */
  8030. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8031. private _decompose;
  8032. private _compose;
  8033. /**
  8034. * Update the base and local matrices
  8035. * @param matrix defines the new base or local matrix
  8036. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8037. * @param updateLocalMatrix defines if the local matrix should be updated
  8038. */
  8039. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8040. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8041. /**
  8042. * Flag the bone as dirty (Forcing it to update everything)
  8043. */
  8044. markAsDirty(): void;
  8045. private _markAsDirtyAndCompose;
  8046. private _markAsDirtyAndDecompose;
  8047. /**
  8048. * Translate the bone in local or world space
  8049. * @param vec The amount to translate the bone
  8050. * @param space The space that the translation is in
  8051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8052. */
  8053. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8054. /**
  8055. * Set the postion of the bone in local or world space
  8056. * @param position The position to set the bone
  8057. * @param space The space that the position is in
  8058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8059. */
  8060. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8061. /**
  8062. * Set the absolute position of the bone (world space)
  8063. * @param position The position to set the bone
  8064. * @param mesh The mesh that this bone is attached to
  8065. */
  8066. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8067. /**
  8068. * Scale the bone on the x, y and z axes (in local space)
  8069. * @param x The amount to scale the bone on the x axis
  8070. * @param y The amount to scale the bone on the y axis
  8071. * @param z The amount to scale the bone on the z axis
  8072. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8073. */
  8074. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8075. /**
  8076. * Set the bone scaling in local space
  8077. * @param scale defines the scaling vector
  8078. */
  8079. setScale(scale: Vector3): void;
  8080. /**
  8081. * Gets the current scaling in local space
  8082. * @returns the current scaling vector
  8083. */
  8084. getScale(): Vector3;
  8085. /**
  8086. * Gets the current scaling in local space and stores it in a target vector
  8087. * @param result defines the target vector
  8088. */
  8089. getScaleToRef(result: Vector3): void;
  8090. /**
  8091. * Set the yaw, pitch, and roll of the bone in local or world space
  8092. * @param yaw The rotation of the bone on the y axis
  8093. * @param pitch The rotation of the bone on the x axis
  8094. * @param roll The rotation of the bone on the z axis
  8095. * @param space The space that the axes of rotation are in
  8096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8097. */
  8098. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8099. /**
  8100. * Add a rotation to the bone on an axis in local or world space
  8101. * @param axis The axis to rotate the bone on
  8102. * @param amount The amount to rotate the bone
  8103. * @param space The space that the axis is in
  8104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8105. */
  8106. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8107. /**
  8108. * Set the rotation of the bone to a particular axis angle in local or world space
  8109. * @param axis The axis to rotate the bone on
  8110. * @param angle The angle that the bone should be rotated to
  8111. * @param space The space that the axis is in
  8112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8113. */
  8114. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8115. /**
  8116. * Set the euler rotation of the bone in local of world space
  8117. * @param rotation The euler rotation that the bone should be set to
  8118. * @param space The space that the rotation is in
  8119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8120. */
  8121. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8122. /**
  8123. * Set the quaternion rotation of the bone in local of world space
  8124. * @param quat The quaternion rotation that the bone should be set to
  8125. * @param space The space that the rotation is in
  8126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8127. */
  8128. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Set the rotation matrix of the bone in local of world space
  8131. * @param rotMat The rotation matrix that the bone should be set to
  8132. * @param space The space that the rotation is in
  8133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8134. */
  8135. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8136. private _rotateWithMatrix;
  8137. private _getNegativeRotationToRef;
  8138. /**
  8139. * Get the position of the bone in local or world space
  8140. * @param space The space that the returned position is in
  8141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8142. * @returns The position of the bone
  8143. */
  8144. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8145. /**
  8146. * Copy the position of the bone to a vector3 in local or world space
  8147. * @param space The space that the returned position is in
  8148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8149. * @param result The vector3 to copy the position to
  8150. */
  8151. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8152. /**
  8153. * Get the absolute position of the bone (world space)
  8154. * @param mesh The mesh that this bone is attached to
  8155. * @returns The absolute position of the bone
  8156. */
  8157. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8158. /**
  8159. * Copy the absolute position of the bone (world space) to the result param
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @param result The vector3 to copy the absolute position to
  8162. */
  8163. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8164. /**
  8165. * Compute the absolute transforms of this bone and its children
  8166. */
  8167. computeAbsoluteTransforms(): void;
  8168. /**
  8169. * Get the world direction from an axis that is in the local space of the bone
  8170. * @param localAxis The local direction that is used to compute the world direction
  8171. * @param mesh The mesh that this bone is attached to
  8172. * @returns The world direction
  8173. */
  8174. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8175. /**
  8176. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8177. * @param localAxis The local direction that is used to compute the world direction
  8178. * @param mesh The mesh that this bone is attached to
  8179. * @param result The vector3 that the world direction will be copied to
  8180. */
  8181. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8182. /**
  8183. * Get the euler rotation of the bone in local or world space
  8184. * @param space The space that the rotation should be in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. * @returns The euler rotation
  8187. */
  8188. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8189. /**
  8190. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8191. * @param space The space that the rotation should be in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. * @param result The vector3 that the rotation should be copied to
  8194. */
  8195. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8196. /**
  8197. * Get the quaternion rotation of the bone in either local or world space
  8198. * @param space The space that the rotation should be in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. * @returns The quaternion rotation
  8201. */
  8202. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8203. /**
  8204. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8205. * @param space The space that the rotation should be in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. * @param result The quaternion that the rotation should be copied to
  8208. */
  8209. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8210. /**
  8211. * Get the rotation matrix of the bone in local or world space
  8212. * @param space The space that the rotation should be in
  8213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8214. * @returns The rotation matrix
  8215. */
  8216. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8217. /**
  8218. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8219. * @param space The space that the rotation should be in
  8220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8221. * @param result The quaternion that the rotation should be copied to
  8222. */
  8223. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8224. /**
  8225. * Get the world position of a point that is in the local space of the bone
  8226. * @param position The local position
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @returns The world position
  8229. */
  8230. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8233. * @param position The local position
  8234. * @param mesh The mesh that this bone is attached to
  8235. * @param result The vector3 that the world position should be copied to
  8236. */
  8237. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8238. /**
  8239. * Get the local position of a point that is in world space
  8240. * @param position The world position
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @returns The local position
  8243. */
  8244. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8245. /**
  8246. * Get the local position of a point that is in world space and copy it to the result param
  8247. * @param position The world position
  8248. * @param mesh The mesh that this bone is attached to
  8249. * @param result The vector3 that the local position should be copied to
  8250. */
  8251. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8252. }
  8253. }
  8254. declare module BABYLON {
  8255. /**
  8256. * Enum that determines the text-wrapping mode to use.
  8257. */
  8258. export enum InspectableType {
  8259. /**
  8260. * Checkbox for booleans
  8261. */
  8262. Checkbox = 0,
  8263. /**
  8264. * Sliders for numbers
  8265. */
  8266. Slider = 1,
  8267. /**
  8268. * Vector3
  8269. */
  8270. Vector3 = 2,
  8271. /**
  8272. * Quaternions
  8273. */
  8274. Quaternion = 3,
  8275. /**
  8276. * Color3
  8277. */
  8278. Color3 = 4
  8279. }
  8280. /**
  8281. * Interface used to define custom inspectable properties.
  8282. * This interface is used by the inspector to display custom property grids
  8283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8284. */
  8285. export interface IInspectable {
  8286. /**
  8287. * Gets the label to display
  8288. */
  8289. label: string;
  8290. /**
  8291. * Gets the name of the property to edit
  8292. */
  8293. propertyName: string;
  8294. /**
  8295. * Gets the type of the editor to use
  8296. */
  8297. type: InspectableType;
  8298. /**
  8299. * Gets the minimum value of the property when using in "slider" mode
  8300. */
  8301. min?: number;
  8302. /**
  8303. * Gets the maximum value of the property when using in "slider" mode
  8304. */
  8305. max?: number;
  8306. /**
  8307. * Gets the setp to use when using in "slider" mode
  8308. */
  8309. step?: number;
  8310. }
  8311. }
  8312. declare module BABYLON {
  8313. /**
  8314. * This represents the required contract to create a new type of texture loader.
  8315. */
  8316. export interface IInternalTextureLoader {
  8317. /**
  8318. * Defines wether the loader supports cascade loading the different faces.
  8319. */
  8320. supportCascades: boolean;
  8321. /**
  8322. * This returns if the loader support the current file information.
  8323. * @param extension defines the file extension of the file being loaded
  8324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8325. * @param fallback defines the fallback internal texture if any
  8326. * @param isBase64 defines whether the texture is encoded as a base64
  8327. * @param isBuffer defines whether the texture data are stored as a buffer
  8328. * @returns true if the loader can load the specified file
  8329. */
  8330. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8331. /**
  8332. * Transform the url before loading if required.
  8333. * @param rootUrl the url of the texture
  8334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8335. * @returns the transformed texture
  8336. */
  8337. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8338. /**
  8339. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8340. * @param rootUrl the url of the texture
  8341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8342. * @returns the fallback texture
  8343. */
  8344. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8345. /**
  8346. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8347. * @param data contains the texture data
  8348. * @param texture defines the BabylonJS internal texture
  8349. * @param createPolynomials will be true if polynomials have been requested
  8350. * @param onLoad defines the callback to trigger once the texture is ready
  8351. * @param onError defines the callback to trigger in case of error
  8352. */
  8353. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8354. /**
  8355. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8356. * @param data contains the texture data
  8357. * @param texture defines the BabylonJS internal texture
  8358. * @param callback defines the method to call once ready to upload
  8359. */
  8360. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8361. }
  8362. }
  8363. declare module BABYLON {
  8364. interface Engine {
  8365. /**
  8366. * Creates a depth stencil cube texture.
  8367. * This is only available in WebGL 2.
  8368. * @param size The size of face edge in the cube texture.
  8369. * @param options The options defining the cube texture.
  8370. * @returns The cube texture
  8371. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8372. /**
  8373. * Creates a cube texture
  8374. * @param rootUrl defines the url where the files to load is located
  8375. * @param scene defines the current scene
  8376. * @param files defines the list of files to load (1 per face)
  8377. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8378. * @param onLoad defines an optional callback raised when the texture is loaded
  8379. * @param onError defines an optional callback raised if there is an issue to load the texture
  8380. * @param format defines the format of the data
  8381. * @param forcedExtension defines the extension to use to pick the right loader
  8382. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8383. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8384. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8385. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8386. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8387. * @returns the cube texture as an InternalTexture
  8388. */
  8389. 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;
  8390. /**
  8391. * Creates a cube texture
  8392. * @param rootUrl defines the url where the files to load is located
  8393. * @param scene defines the current scene
  8394. * @param files defines the list of files to load (1 per face)
  8395. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8396. * @param onLoad defines an optional callback raised when the texture is loaded
  8397. * @param onError defines an optional callback raised if there is an issue to load the texture
  8398. * @param format defines the format of the data
  8399. * @param forcedExtension defines the extension to use to pick the right loader
  8400. * @returns the cube texture as an InternalTexture
  8401. */
  8402. 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;
  8403. /**
  8404. * Creates a cube texture
  8405. * @param rootUrl defines the url where the files to load is located
  8406. * @param scene defines the current scene
  8407. * @param files defines the list of files to load (1 per face)
  8408. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8409. * @param onLoad defines an optional callback raised when the texture is loaded
  8410. * @param onError defines an optional callback raised if there is an issue to load the texture
  8411. * @param format defines the format of the data
  8412. * @param forcedExtension defines the extension to use to pick the right loader
  8413. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8414. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8415. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8416. * @returns the cube texture as an InternalTexture
  8417. */
  8418. 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;
  8419. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8420. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8421. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8422. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8423. }
  8424. }
  8425. declare module BABYLON {
  8426. /**
  8427. * Class for creating a cube texture
  8428. */
  8429. export class CubeTexture extends BaseTexture {
  8430. private _delayedOnLoad;
  8431. /**
  8432. * The url of the texture
  8433. */
  8434. url: string;
  8435. /**
  8436. * Gets or sets the center of the bounding box associated with the cube texture.
  8437. * It must define where the camera used to render the texture was set
  8438. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8439. */
  8440. boundingBoxPosition: Vector3;
  8441. private _boundingBoxSize;
  8442. /**
  8443. * Gets or sets the size of the bounding box associated with the cube texture
  8444. * When defined, the cubemap will switch to local mode
  8445. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8446. * @example https://www.babylonjs-playground.com/#RNASML
  8447. */
  8448. /**
  8449. * Returns the bounding box size
  8450. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8451. */
  8452. boundingBoxSize: Vector3;
  8453. protected _rotationY: number;
  8454. /**
  8455. * Sets texture matrix rotation angle around Y axis in radians.
  8456. */
  8457. /**
  8458. * Gets texture matrix rotation angle around Y axis radians.
  8459. */
  8460. rotationY: number;
  8461. /**
  8462. * Are mip maps generated for this texture or not.
  8463. */
  8464. readonly noMipmap: boolean;
  8465. private _noMipmap;
  8466. private _files;
  8467. private _extensions;
  8468. private _textureMatrix;
  8469. private _format;
  8470. private _createPolynomials;
  8471. /** @hidden */ private _prefiltered: boolean;
  8472. /**
  8473. * Creates a cube texture from an array of image urls
  8474. * @param files defines an array of image urls
  8475. * @param scene defines the hosting scene
  8476. * @param noMipmap specifies if mip maps are not used
  8477. * @returns a cube texture
  8478. */
  8479. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8480. /**
  8481. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8482. * @param url defines the url of the prefiltered texture
  8483. * @param scene defines the scene the texture is attached to
  8484. * @param forcedExtension defines the extension of the file if different from the url
  8485. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8486. * @return the prefiltered texture
  8487. */
  8488. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8489. /**
  8490. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8491. * as prefiltered data.
  8492. * @param rootUrl defines the url of the texture or the root name of the six images
  8493. * @param scene defines the scene the texture is attached to
  8494. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8495. * @param noMipmap defines if mipmaps should be created or not
  8496. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8497. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8498. * @param onError defines a callback triggered in case of error during load
  8499. * @param format defines the internal format to use for the texture once loaded
  8500. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8501. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8502. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8505. * @return the cube texture
  8506. */
  8507. 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);
  8508. /**
  8509. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8510. */
  8511. readonly isPrefiltered: boolean;
  8512. /**
  8513. * Get the current class name of the texture useful for serialization or dynamic coding.
  8514. * @returns "CubeTexture"
  8515. */
  8516. getClassName(): string;
  8517. /**
  8518. * Update the url (and optional buffer) of this texture if url was null during construction.
  8519. * @param url the url of the texture
  8520. * @param forcedExtension defines the extension to use
  8521. * @param onLoad callback called when the texture is loaded (defaults to null)
  8522. */
  8523. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8524. /**
  8525. * Delays loading of the cube texture
  8526. * @param forcedExtension defines the extension to use
  8527. */
  8528. delayLoad(forcedExtension?: string): void;
  8529. /**
  8530. * Returns the reflection texture matrix
  8531. * @returns the reflection texture matrix
  8532. */
  8533. getReflectionTextureMatrix(): Matrix;
  8534. /**
  8535. * Sets the reflection texture matrix
  8536. * @param value Reflection texture matrix
  8537. */
  8538. setReflectionTextureMatrix(value: Matrix): void;
  8539. /**
  8540. * Parses text to create a cube texture
  8541. * @param parsedTexture define the serialized text to read from
  8542. * @param scene defines the hosting scene
  8543. * @param rootUrl defines the root url of the cube texture
  8544. * @returns a cube texture
  8545. */
  8546. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8547. /**
  8548. * Makes a clone, or deep copy, of the cube texture
  8549. * @returns a new cube texture
  8550. */
  8551. clone(): CubeTexture;
  8552. }
  8553. }
  8554. declare module BABYLON {
  8555. /** @hidden */
  8556. export var postprocessVertexShader: {
  8557. name: string;
  8558. shader: string;
  8559. };
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8564. * This is the base of the follow, arc rotate cameras and Free camera
  8565. * @see http://doc.babylonjs.com/features/cameras
  8566. */
  8567. export class TargetCamera extends Camera {
  8568. private static _RigCamTransformMatrix;
  8569. private static _TargetTransformMatrix;
  8570. private static _TargetFocalPoint;
  8571. /**
  8572. * Define the current direction the camera is moving to
  8573. */
  8574. cameraDirection: Vector3;
  8575. /**
  8576. * Define the current rotation the camera is rotating to
  8577. */
  8578. cameraRotation: Vector2;
  8579. /**
  8580. * When set, the up vector of the camera will be updated by the rotation of the camera
  8581. */
  8582. updateUpVectorFromRotation: boolean;
  8583. private _tmpQuaternion;
  8584. /**
  8585. * Define the current rotation of the camera
  8586. */
  8587. rotation: Vector3;
  8588. /**
  8589. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8590. */
  8591. rotationQuaternion: Quaternion;
  8592. /**
  8593. * Define the current speed of the camera
  8594. */
  8595. speed: number;
  8596. /**
  8597. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8598. * around all axis.
  8599. */
  8600. noRotationConstraint: boolean;
  8601. /**
  8602. * Define the current target of the camera as an object or a position.
  8603. */
  8604. lockedTarget: any;
  8605. /** @hidden */ private _currentTarget: Vector3;
  8606. /** @hidden */ private _initialFocalDistance: number;
  8607. /** @hidden */ private _viewMatrix: Matrix;
  8608. /** @hidden */ private _camMatrix: Matrix;
  8609. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8610. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8611. /** @hidden */ private _referencePoint: Vector3;
  8612. /** @hidden */ private _transformedReferencePoint: Vector3;
  8613. protected _globalCurrentTarget: Vector3;
  8614. protected _globalCurrentUpVector: Vector3;
  8615. /** @hidden */ private _reset: () => void;
  8616. private _defaultUp;
  8617. /**
  8618. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8619. * This is the base of the follow, arc rotate cameras and Free camera
  8620. * @see http://doc.babylonjs.com/features/cameras
  8621. * @param name Defines the name of the camera in the scene
  8622. * @param position Defines the start position of the camera in the scene
  8623. * @param scene Defines the scene the camera belongs to
  8624. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8625. */
  8626. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8627. /**
  8628. * Gets the position in front of the camera at a given distance.
  8629. * @param distance The distance from the camera we want the position to be
  8630. * @returns the position
  8631. */
  8632. getFrontPosition(distance: number): Vector3;
  8633. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8634. private _storedPosition;
  8635. private _storedRotation;
  8636. private _storedRotationQuaternion;
  8637. /**
  8638. * Store current camera state of the camera (fov, position, rotation, etc..)
  8639. * @returns the camera
  8640. */
  8641. storeState(): Camera;
  8642. /**
  8643. * Restored camera state. You must call storeState() first
  8644. * @returns whether it was successful or not
  8645. * @hidden
  8646. */ private _restoreStateValues(): boolean;
  8647. /** @hidden */ private _initCache(): void;
  8648. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8649. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8650. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8651. /**
  8652. * Defines the target the camera should look at.
  8653. * This will automatically adapt alpha beta and radius to fit within the new target.
  8654. * @param target Defines the new target as a Vector or a mesh
  8655. */
  8656. setTarget(target: Vector3): void;
  8657. /**
  8658. * Return the current target position of the camera. This value is expressed in local space.
  8659. * @returns the target position
  8660. */
  8661. getTarget(): Vector3;
  8662. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8663. /** @hidden */ private _updatePosition(): void;
  8664. /** @hidden */ private _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */ private _getViewMatrix(): Matrix;
  8674. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8675. /**
  8676. * @hidden
  8677. */
  8678. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8679. /**
  8680. * @hidden
  8681. */ private _updateRigCameras(): void;
  8682. private _getRigCamPositionAndTarget;
  8683. /**
  8684. * Gets the current object class name.
  8685. * @return the class name
  8686. */
  8687. getClassName(): string;
  8688. }
  8689. }
  8690. declare module BABYLON {
  8691. /**
  8692. * @ignore
  8693. * This is a list of all the different input types that are available in the application.
  8694. * Fo instance: ArcRotateCameraGamepadInput...
  8695. */
  8696. export var CameraInputTypes: {};
  8697. /**
  8698. * This is the contract to implement in order to create a new input class.
  8699. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8700. */
  8701. export interface ICameraInput<TCamera extends Camera> {
  8702. /**
  8703. * Defines the camera the input is attached to.
  8704. */
  8705. camera: Nullable<TCamera>;
  8706. /**
  8707. * Gets the class name of the current intput.
  8708. * @returns the class name
  8709. */
  8710. getClassName(): string;
  8711. /**
  8712. * Get the friendly name associated with the input class.
  8713. * @returns the input friendly name
  8714. */
  8715. getSimpleName(): string;
  8716. /**
  8717. * Attach the input controls to a specific dom element to get the input from.
  8718. * @param element Defines the element the controls should be listened from
  8719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8720. */
  8721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8722. /**
  8723. * Detach the current controls from the specified dom element.
  8724. * @param element Defines the element to stop listening the inputs from
  8725. */
  8726. detachControl(element: Nullable<HTMLElement>): void;
  8727. /**
  8728. * Update the current camera state depending on the inputs that have been used this frame.
  8729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8730. */
  8731. checkInputs?: () => void;
  8732. }
  8733. /**
  8734. * Represents a map of input types to input instance or input index to input instance.
  8735. */
  8736. export interface CameraInputsMap<TCamera extends Camera> {
  8737. /**
  8738. * Accessor to the input by input type.
  8739. */
  8740. [name: string]: ICameraInput<TCamera>;
  8741. /**
  8742. * Accessor to the input by input index.
  8743. */
  8744. [idx: number]: ICameraInput<TCamera>;
  8745. }
  8746. /**
  8747. * This represents the input manager used within a camera.
  8748. * It helps dealing with all the different kind of input attached to a camera.
  8749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8750. */
  8751. export class CameraInputsManager<TCamera extends Camera> {
  8752. /**
  8753. * Defines the list of inputs attahed to the camera.
  8754. */
  8755. attached: CameraInputsMap<TCamera>;
  8756. /**
  8757. * Defines the dom element the camera is collecting inputs from.
  8758. * This is null if the controls have not been attached.
  8759. */
  8760. attachedElement: Nullable<HTMLElement>;
  8761. /**
  8762. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8763. */
  8764. noPreventDefault: boolean;
  8765. /**
  8766. * Defined the camera the input manager belongs to.
  8767. */
  8768. camera: TCamera;
  8769. /**
  8770. * Update the current camera state depending on the inputs that have been used this frame.
  8771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8772. */
  8773. checkInputs: () => void;
  8774. /**
  8775. * Instantiate a new Camera Input Manager.
  8776. * @param camera Defines the camera the input manager blongs to
  8777. */
  8778. constructor(camera: TCamera);
  8779. /**
  8780. * Add an input method to a camera
  8781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8782. * @param input camera input method
  8783. */
  8784. add(input: ICameraInput<TCamera>): void;
  8785. /**
  8786. * Remove a specific input method from a camera
  8787. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8788. * @param inputToRemove camera input method
  8789. */
  8790. remove(inputToRemove: ICameraInput<TCamera>): void;
  8791. /**
  8792. * Remove a specific input type from a camera
  8793. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8794. * @param inputType the type of the input to remove
  8795. */
  8796. removeByType(inputType: string): void;
  8797. private _addCheckInputs;
  8798. /**
  8799. * Attach the input controls to the currently attached dom element to listen the events from.
  8800. * @param input Defines the input to attach
  8801. */
  8802. attachInput(input: ICameraInput<TCamera>): void;
  8803. /**
  8804. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8805. * @param element Defines the dom element to collect the events from
  8806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8807. */
  8808. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8809. /**
  8810. * Detach the current manager inputs controls from a specific dom element.
  8811. * @param element Defines the dom element to collect the events from
  8812. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8813. */
  8814. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8815. /**
  8816. * Rebuild the dynamic inputCheck function from the current list of
  8817. * defined inputs in the manager.
  8818. */
  8819. rebuildInputCheck(): void;
  8820. /**
  8821. * Remove all attached input methods from a camera
  8822. */
  8823. clear(): void;
  8824. /**
  8825. * Serialize the current input manager attached to a camera.
  8826. * This ensures than once parsed,
  8827. * the input associated to the camera will be identical to the current ones
  8828. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8829. */
  8830. serialize(serializedCamera: any): void;
  8831. /**
  8832. * Parses an input manager serialized JSON to restore the previous list of inputs
  8833. * and states associated to a camera.
  8834. * @param parsedCamera Defines the JSON to parse
  8835. */
  8836. parse(parsedCamera: any): void;
  8837. }
  8838. }
  8839. declare module BABYLON {
  8840. /**
  8841. * Gather the list of keyboard event types as constants.
  8842. */
  8843. export class KeyboardEventTypes {
  8844. /**
  8845. * The keydown event is fired when a key becomes active (pressed).
  8846. */
  8847. static readonly KEYDOWN: number;
  8848. /**
  8849. * The keyup event is fired when a key has been released.
  8850. */
  8851. static readonly KEYUP: number;
  8852. }
  8853. /**
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. */
  8856. export class KeyboardInfo {
  8857. /**
  8858. * Defines the type of event (KeyboardEventTypes)
  8859. */
  8860. type: number;
  8861. /**
  8862. * Defines the related dom event
  8863. */
  8864. event: KeyboardEvent;
  8865. /**
  8866. * Instantiates a new keyboard info.
  8867. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8868. * @param type Defines the type of event (KeyboardEventTypes)
  8869. * @param event Defines the related dom event
  8870. */
  8871. constructor(
  8872. /**
  8873. * Defines the type of event (KeyboardEventTypes)
  8874. */
  8875. type: number,
  8876. /**
  8877. * Defines the related dom event
  8878. */
  8879. event: KeyboardEvent);
  8880. }
  8881. /**
  8882. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8883. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8884. */
  8885. export class KeyboardInfoPre extends KeyboardInfo {
  8886. /**
  8887. * Defines the type of event (KeyboardEventTypes)
  8888. */
  8889. type: number;
  8890. /**
  8891. * Defines the related dom event
  8892. */
  8893. event: KeyboardEvent;
  8894. /**
  8895. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8896. */
  8897. skipOnPointerObservable: boolean;
  8898. /**
  8899. * Instantiates a new keyboard pre info.
  8900. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8901. * @param type Defines the type of event (KeyboardEventTypes)
  8902. * @param event Defines the related dom event
  8903. */
  8904. constructor(
  8905. /**
  8906. * Defines the type of event (KeyboardEventTypes)
  8907. */
  8908. type: number,
  8909. /**
  8910. * Defines the related dom event
  8911. */
  8912. event: KeyboardEvent);
  8913. }
  8914. }
  8915. declare module BABYLON {
  8916. /**
  8917. * Manage the keyboard inputs to control the movement of a free camera.
  8918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8919. */
  8920. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8921. /**
  8922. * Defines the camera the input is attached to.
  8923. */
  8924. camera: FreeCamera;
  8925. /**
  8926. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8927. */
  8928. keysUp: number[];
  8929. /**
  8930. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8931. */
  8932. keysDown: number[];
  8933. /**
  8934. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8935. */
  8936. keysLeft: number[];
  8937. /**
  8938. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8939. */
  8940. keysRight: number[];
  8941. private _keys;
  8942. private _onCanvasBlurObserver;
  8943. private _onKeyboardObserver;
  8944. private _engine;
  8945. private _scene;
  8946. /**
  8947. * Attach the input controls to a specific dom element to get the input from.
  8948. * @param element Defines the element the controls should be listened from
  8949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8950. */
  8951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8952. /**
  8953. * Detach the current controls from the specified dom element.
  8954. * @param element Defines the element to stop listening the inputs from
  8955. */
  8956. detachControl(element: Nullable<HTMLElement>): void;
  8957. /**
  8958. * Update the current camera state depending on the inputs that have been used this frame.
  8959. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8960. */
  8961. checkInputs(): void;
  8962. /**
  8963. * Gets the class name of the current intput.
  8964. * @returns the class name
  8965. */
  8966. getClassName(): string;
  8967. /** @hidden */ private _onLostFocus(): void;
  8968. /**
  8969. * Get the friendly name associated with the input class.
  8970. * @returns the input friendly name
  8971. */
  8972. getSimpleName(): string;
  8973. }
  8974. }
  8975. declare module BABYLON {
  8976. /**
  8977. * Interface describing all the common properties and methods a shadow light needs to implement.
  8978. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8979. * as well as binding the different shadow properties to the effects.
  8980. */
  8981. export interface IShadowLight extends Light {
  8982. /**
  8983. * The light id in the scene (used in scene.findLighById for instance)
  8984. */
  8985. id: string;
  8986. /**
  8987. * The position the shdow will be casted from.
  8988. */
  8989. position: Vector3;
  8990. /**
  8991. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8992. */
  8993. direction: Vector3;
  8994. /**
  8995. * The transformed position. Position of the light in world space taking parenting in account.
  8996. */
  8997. transformedPosition: Vector3;
  8998. /**
  8999. * The transformed direction. Direction of the light in world space taking parenting in account.
  9000. */
  9001. transformedDirection: Vector3;
  9002. /**
  9003. * The friendly name of the light in the scene.
  9004. */
  9005. name: string;
  9006. /**
  9007. * Defines the shadow projection clipping minimum z value.
  9008. */
  9009. shadowMinZ: number;
  9010. /**
  9011. * Defines the shadow projection clipping maximum z value.
  9012. */
  9013. shadowMaxZ: number;
  9014. /**
  9015. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9016. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9017. */
  9018. computeTransformedInformation(): boolean;
  9019. /**
  9020. * Gets the scene the light belongs to.
  9021. * @returns The scene
  9022. */
  9023. getScene(): Scene;
  9024. /**
  9025. * Callback defining a custom Projection Matrix Builder.
  9026. * This can be used to override the default projection matrix computation.
  9027. */
  9028. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9029. /**
  9030. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9031. * @param matrix The materix to updated with the projection information
  9032. * @param viewMatrix The transform matrix of the light
  9033. * @param renderList The list of mesh to render in the map
  9034. * @returns The current light
  9035. */
  9036. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9037. /**
  9038. * Gets the current depth scale used in ESM.
  9039. * @returns The scale
  9040. */
  9041. getDepthScale(): number;
  9042. /**
  9043. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9044. * @returns true if a cube texture needs to be use
  9045. */
  9046. needCube(): boolean;
  9047. /**
  9048. * Detects if the projection matrix requires to be recomputed this frame.
  9049. * @returns true if it requires to be recomputed otherwise, false.
  9050. */
  9051. needProjectionMatrixCompute(): boolean;
  9052. /**
  9053. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9054. */
  9055. forceProjectionMatrixCompute(): void;
  9056. /**
  9057. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9058. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9059. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9060. */
  9061. getShadowDirection(faceIndex?: number): Vector3;
  9062. /**
  9063. * Gets the minZ used for shadow according to both the scene and the light.
  9064. * @param activeCamera The camera we are returning the min for
  9065. * @returns the depth min z
  9066. */
  9067. getDepthMinZ(activeCamera: Camera): number;
  9068. /**
  9069. * Gets the maxZ used for shadow according to both the scene and the light.
  9070. * @param activeCamera The camera we are returning the max for
  9071. * @returns the depth max z
  9072. */
  9073. getDepthMaxZ(activeCamera: Camera): number;
  9074. }
  9075. /**
  9076. * Base implementation IShadowLight
  9077. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9078. */
  9079. export abstract class ShadowLight extends Light implements IShadowLight {
  9080. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9081. protected _position: Vector3;
  9082. protected _setPosition(value: Vector3): void;
  9083. /**
  9084. * Sets the position the shadow will be casted from. Also use as the light position for both
  9085. * point and spot lights.
  9086. */
  9087. /**
  9088. * Sets the position the shadow will be casted from. Also use as the light position for both
  9089. * point and spot lights.
  9090. */
  9091. position: Vector3;
  9092. protected _direction: Vector3;
  9093. protected _setDirection(value: Vector3): void;
  9094. /**
  9095. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9096. * Also use as the light direction on spot and directional lights.
  9097. */
  9098. /**
  9099. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9100. * Also use as the light direction on spot and directional lights.
  9101. */
  9102. direction: Vector3;
  9103. private _shadowMinZ;
  9104. /**
  9105. * Gets the shadow projection clipping minimum z value.
  9106. */
  9107. /**
  9108. * Sets the shadow projection clipping minimum z value.
  9109. */
  9110. shadowMinZ: number;
  9111. private _shadowMaxZ;
  9112. /**
  9113. * Sets the shadow projection clipping maximum z value.
  9114. */
  9115. /**
  9116. * Gets the shadow projection clipping maximum z value.
  9117. */
  9118. shadowMaxZ: number;
  9119. /**
  9120. * Callback defining a custom Projection Matrix Builder.
  9121. * This can be used to override the default projection matrix computation.
  9122. */
  9123. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9124. /**
  9125. * The transformed position. Position of the light in world space taking parenting in account.
  9126. */
  9127. transformedPosition: Vector3;
  9128. /**
  9129. * The transformed direction. Direction of the light in world space taking parenting in account.
  9130. */
  9131. transformedDirection: Vector3;
  9132. private _needProjectionMatrixCompute;
  9133. /**
  9134. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9135. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9136. */
  9137. computeTransformedInformation(): boolean;
  9138. /**
  9139. * Return the depth scale used for the shadow map.
  9140. * @returns the depth scale.
  9141. */
  9142. getDepthScale(): number;
  9143. /**
  9144. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9145. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9146. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9147. */
  9148. getShadowDirection(faceIndex?: number): Vector3;
  9149. /**
  9150. * Returns the ShadowLight absolute position in the World.
  9151. * @returns the position vector in world space
  9152. */
  9153. getAbsolutePosition(): Vector3;
  9154. /**
  9155. * Sets the ShadowLight direction toward the passed target.
  9156. * @param target The point to target in local space
  9157. * @returns the updated ShadowLight direction
  9158. */
  9159. setDirectionToTarget(target: Vector3): Vector3;
  9160. /**
  9161. * Returns the light rotation in euler definition.
  9162. * @returns the x y z rotation in local space.
  9163. */
  9164. getRotation(): Vector3;
  9165. /**
  9166. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9167. * @returns true if a cube texture needs to be use
  9168. */
  9169. needCube(): boolean;
  9170. /**
  9171. * Detects if the projection matrix requires to be recomputed this frame.
  9172. * @returns true if it requires to be recomputed otherwise, false.
  9173. */
  9174. needProjectionMatrixCompute(): boolean;
  9175. /**
  9176. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9177. */
  9178. forceProjectionMatrixCompute(): void;
  9179. /** @hidden */ private _initCache(): void;
  9180. /** @hidden */ private _isSynchronized(): boolean;
  9181. /**
  9182. * Computes the world matrix of the node
  9183. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9184. * @returns the world matrix
  9185. */
  9186. computeWorldMatrix(force?: boolean): Matrix;
  9187. /**
  9188. * Gets the minZ used for shadow according to both the scene and the light.
  9189. * @param activeCamera The camera we are returning the min for
  9190. * @returns the depth min z
  9191. */
  9192. getDepthMinZ(activeCamera: Camera): number;
  9193. /**
  9194. * Gets the maxZ used for shadow according to both the scene and the light.
  9195. * @param activeCamera The camera we are returning the max for
  9196. * @returns the depth max z
  9197. */
  9198. getDepthMaxZ(activeCamera: Camera): number;
  9199. /**
  9200. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9201. * @param matrix The materix to updated with the projection information
  9202. * @param viewMatrix The transform matrix of the light
  9203. * @param renderList The list of mesh to render in the map
  9204. * @returns The current light
  9205. */
  9206. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9207. }
  9208. }
  9209. declare module BABYLON {
  9210. /**
  9211. * "Static Class" containing the most commonly used helper while dealing with material for
  9212. * rendering purpose.
  9213. *
  9214. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9215. *
  9216. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9217. */
  9218. export class MaterialHelper {
  9219. /**
  9220. * Bind the current view position to an effect.
  9221. * @param effect The effect to be bound
  9222. * @param scene The scene the eyes position is used from
  9223. */
  9224. static BindEyePosition(effect: Effect, scene: Scene): void;
  9225. /**
  9226. * Helps preparing the defines values about the UVs in used in the effect.
  9227. * UVs are shared as much as we can accross channels in the shaders.
  9228. * @param texture The texture we are preparing the UVs for
  9229. * @param defines The defines to update
  9230. * @param key The channel key "diffuse", "specular"... used in the shader
  9231. */
  9232. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9233. /**
  9234. * Binds a texture matrix value to its corrsponding uniform
  9235. * @param texture The texture to bind the matrix for
  9236. * @param uniformBuffer The uniform buffer receivin the data
  9237. * @param key The channel key "diffuse", "specular"... used in the shader
  9238. */
  9239. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9240. /**
  9241. * Gets the current status of the fog (should it be enabled?)
  9242. * @param mesh defines the mesh to evaluate for fog support
  9243. * @param scene defines the hosting scene
  9244. * @returns true if fog must be enabled
  9245. */
  9246. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9247. /**
  9248. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9249. * @param mesh defines the current mesh
  9250. * @param scene defines the current scene
  9251. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9252. * @param pointsCloud defines if point cloud rendering has to be turned on
  9253. * @param fogEnabled defines if fog has to be turned on
  9254. * @param alphaTest defines if alpha testing has to be turned on
  9255. * @param defines defines the current list of defines
  9256. */
  9257. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9258. /**
  9259. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9260. * @param scene defines the current scene
  9261. * @param engine defines the current engine
  9262. * @param defines specifies the list of active defines
  9263. * @param useInstances defines if instances have to be turned on
  9264. * @param useClipPlane defines if clip plane have to be turned on
  9265. */
  9266. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9267. /**
  9268. * Prepares the defines for bones
  9269. * @param mesh The mesh containing the geometry data we will draw
  9270. * @param defines The defines to update
  9271. */
  9272. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9273. /**
  9274. * Prepares the defines for morph targets
  9275. * @param mesh The mesh containing the geometry data we will draw
  9276. * @param defines The defines to update
  9277. */
  9278. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9279. /**
  9280. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9281. * @param mesh The mesh containing the geometry data we will draw
  9282. * @param defines The defines to update
  9283. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9284. * @param useBones Precise whether bones should be used or not (override mesh info)
  9285. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9286. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9287. * @returns false if defines are considered not dirty and have not been checked
  9288. */
  9289. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9290. /**
  9291. * Prepares the defines related to multiview
  9292. * @param scene The scene we are intending to draw
  9293. * @param defines The defines to update
  9294. */
  9295. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9296. /**
  9297. * Prepares the defines related to the light information passed in parameter
  9298. * @param scene The scene we are intending to draw
  9299. * @param mesh The mesh the effect is compiling for
  9300. * @param defines The defines to update
  9301. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9302. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9303. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9304. * @returns true if normals will be required for the rest of the effect
  9305. */
  9306. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9307. /**
  9308. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9309. * that won t be acctive due to defines being turned off.
  9310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9311. * @param samplersList The samplers list
  9312. * @param defines The defines helping in the list generation
  9313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9314. */
  9315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9316. /**
  9317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9318. * @param defines The defines to update while falling back
  9319. * @param fallbacks The authorized effect fallbacks
  9320. * @param maxSimultaneousLights The maximum number of lights allowed
  9321. * @param rank the current rank of the Effect
  9322. * @returns The newly affected rank
  9323. */
  9324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9325. /**
  9326. * Prepares the list of attributes required for morph targets according to the effect defines.
  9327. * @param attribs The current list of supported attribs
  9328. * @param mesh The mesh to prepare the morph targets attributes for
  9329. * @param defines The current Defines of the effect
  9330. */
  9331. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9332. /**
  9333. * Prepares the list of attributes required for bones according to the effect defines.
  9334. * @param attribs The current list of supported attribs
  9335. * @param mesh The mesh to prepare the bones attributes for
  9336. * @param defines The current Defines of the effect
  9337. * @param fallbacks The current efffect fallback strategy
  9338. */
  9339. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9340. /**
  9341. * Prepares the list of attributes required for instances according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param defines The current Defines of the effect
  9344. */
  9345. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9346. /**
  9347. * Binds the light shadow information to the effect for the given mesh.
  9348. * @param light The light containing the generator
  9349. * @param scene The scene the lights belongs to
  9350. * @param mesh The mesh we are binding the information to render
  9351. * @param lightIndex The light index in the effect used to render the mesh
  9352. * @param effect The effect we are binding the data to
  9353. */
  9354. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9355. /**
  9356. * Binds the light information to the effect.
  9357. * @param light The light containing the generator
  9358. * @param effect The effect we are binding the data to
  9359. * @param lightIndex The light index in the effect used to render
  9360. */
  9361. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9362. /**
  9363. * Binds the lights information from the scene to the effect for the given mesh.
  9364. * @param scene The scene the lights belongs to
  9365. * @param mesh The mesh we are binding the information to render
  9366. * @param effect The effect we are binding the data to
  9367. * @param defines The generated defines for the effect
  9368. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9369. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9370. */
  9371. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9372. private static _tempFogColor;
  9373. /**
  9374. * Binds the fog information from the scene to the effect for the given mesh.
  9375. * @param scene The scene the lights belongs to
  9376. * @param mesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. * @param linearSpace Defines if the fog effect is applied in linear space
  9379. */
  9380. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9381. /**
  9382. * Binds the bones information from the mesh to the effect.
  9383. * @param mesh The mesh we are binding the information to render
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9387. /**
  9388. * Binds the morph targets information from the mesh to the effect.
  9389. * @param abstractMesh The mesh we are binding the information to render
  9390. * @param effect The effect we are binding the data to
  9391. */
  9392. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9393. /**
  9394. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9395. * @param defines The generated defines used in the effect
  9396. * @param effect The effect we are binding the data to
  9397. * @param scene The scene we are willing to render with logarithmic scale for
  9398. */
  9399. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9400. /**
  9401. * Binds the clip plane information from the scene to the effect.
  9402. * @param scene The scene the clip plane information are extracted from
  9403. * @param effect The effect we are binding the data to
  9404. */
  9405. static BindClipPlane(effect: Effect, scene: Scene): void;
  9406. }
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var kernelBlurVaryingDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var kernelBlurFragment: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var kernelBlurFragment2: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var kernelBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var kernelBlurVertex: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var kernelBlurVertexShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /**
  9452. * The Blur Post Process which blurs an image based on a kernel and direction.
  9453. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9454. */
  9455. export class BlurPostProcess extends PostProcess {
  9456. /** The direction in which to blur the image. */
  9457. direction: Vector2;
  9458. private blockCompilation;
  9459. protected _kernel: number;
  9460. protected _idealKernel: number;
  9461. protected _packedFloat: boolean;
  9462. private _staticDefines;
  9463. /**
  9464. * Sets the length in pixels of the blur sample region
  9465. */
  9466. /**
  9467. * Gets the length in pixels of the blur sample region
  9468. */
  9469. kernel: number;
  9470. /**
  9471. * Sets wether or not the blur needs to unpack/repack floats
  9472. */
  9473. /**
  9474. * Gets wether or not the blur is unpacking/repacking floats
  9475. */
  9476. packedFloat: boolean;
  9477. /**
  9478. * Creates a new instance BlurPostProcess
  9479. * @param name The name of the effect.
  9480. * @param direction The direction in which to blur the image.
  9481. * @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.
  9482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9483. * @param camera The camera to apply the render pass to.
  9484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9485. * @param engine The engine which the post process will be applied. (default: current engine)
  9486. * @param reusable If the post process can be reused on the same frame. (default: false)
  9487. * @param textureType Type of textures used when performing the post process. (default: 0)
  9488. * @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)
  9489. */
  9490. constructor(name: string,
  9491. /** The direction in which to blur the image. */
  9492. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9493. /**
  9494. * Updates the effect with the current post process compile time values and recompiles the shader.
  9495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9498. * @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
  9499. * @param onCompiled Called when the shader has been compiled.
  9500. * @param onError Called if there is an error when compiling a shader.
  9501. */
  9502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9503. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9504. /**
  9505. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9506. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9507. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9508. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9509. * The gaps between physical kernels are compensated for in the weighting of the samples
  9510. * @param idealKernel Ideal blur kernel.
  9511. * @return Nearest best kernel.
  9512. */
  9513. protected _nearestBestKernel(idealKernel: number): number;
  9514. /**
  9515. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9516. * @param x The point on the Gaussian distribution to sample.
  9517. * @return the value of the Gaussian function at x.
  9518. */
  9519. protected _gaussianWeight(x: number): number;
  9520. /**
  9521. * Generates a string that can be used as a floating point number in GLSL.
  9522. * @param x Value to print.
  9523. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9524. * @return GLSL float string.
  9525. */
  9526. protected _glslFloat(x: number, decimalFigures?: number): string;
  9527. }
  9528. }
  9529. declare module BABYLON {
  9530. /** @hidden */
  9531. export var shadowMapPixelShader: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module BABYLON {
  9537. /** @hidden */
  9538. export var bonesDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module BABYLON {
  9544. /** @hidden */
  9545. export var morphTargetsVertexGlobalDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module BABYLON {
  9551. /** @hidden */
  9552. export var morphTargetsVertexDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module BABYLON {
  9558. /** @hidden */
  9559. export var instancesDeclaration: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module BABYLON {
  9565. /** @hidden */
  9566. export var helperFunctions: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module BABYLON {
  9572. /** @hidden */
  9573. export var morphTargetsVertex: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module BABYLON {
  9579. /** @hidden */
  9580. export var instancesVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module BABYLON {
  9586. /** @hidden */
  9587. export var bonesVertex: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module BABYLON {
  9593. /** @hidden */
  9594. export var shadowMapVertexShader: {
  9595. name: string;
  9596. shader: string;
  9597. };
  9598. }
  9599. declare module BABYLON {
  9600. /** @hidden */
  9601. export var depthBoxBlurPixelShader: {
  9602. name: string;
  9603. shader: string;
  9604. };
  9605. }
  9606. declare module BABYLON {
  9607. /**
  9608. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9609. */
  9610. export interface ICustomShaderOptions {
  9611. /**
  9612. * Gets or sets the custom shader name to use
  9613. */
  9614. shaderName: string;
  9615. /**
  9616. * The list of attribute names used in the shader
  9617. */
  9618. attributes?: string[];
  9619. /**
  9620. * The list of unifrom names used in the shader
  9621. */
  9622. uniforms?: string[];
  9623. /**
  9624. * The list of sampler names used in the shader
  9625. */
  9626. samplers?: string[];
  9627. /**
  9628. * The list of defines used in the shader
  9629. */
  9630. defines?: string[];
  9631. }
  9632. /**
  9633. * Interface to implement to create a shadow generator compatible with BJS.
  9634. */
  9635. export interface IShadowGenerator {
  9636. /**
  9637. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9638. * @returns The render target texture if present otherwise, null
  9639. */
  9640. getShadowMap(): Nullable<RenderTargetTexture>;
  9641. /**
  9642. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9643. * @returns The render target texture if the shadow map is present otherwise, null
  9644. */
  9645. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9646. /**
  9647. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9648. * @param subMesh The submesh we want to render in the shadow map
  9649. * @param useInstances Defines wether will draw in the map using instances
  9650. * @returns true if ready otherwise, false
  9651. */
  9652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9653. /**
  9654. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9655. * @param defines Defines of the material we want to update
  9656. * @param lightIndex Index of the light in the enabled light list of the material
  9657. */
  9658. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9659. /**
  9660. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9661. * defined in the generator but impacting the effect).
  9662. * It implies the unifroms available on the materials are the standard BJS ones.
  9663. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9664. * @param effect The effect we are binfing the information for
  9665. */
  9666. bindShadowLight(lightIndex: string, effect: Effect): void;
  9667. /**
  9668. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9669. * (eq to shadow prjection matrix * light transform matrix)
  9670. * @returns The transform matrix used to create the shadow map
  9671. */
  9672. getTransformMatrix(): Matrix;
  9673. /**
  9674. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9675. * Cube and 2D textures for instance.
  9676. */
  9677. recreateShadowMap(): void;
  9678. /**
  9679. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9680. * @param onCompiled Callback triggered at the and of the effects compilation
  9681. * @param options Sets of optional options forcing the compilation with different modes
  9682. */
  9683. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9684. useInstances: boolean;
  9685. }>): void;
  9686. /**
  9687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9688. * @param options Sets of optional options forcing the compilation with different modes
  9689. * @returns A promise that resolves when the compilation completes
  9690. */
  9691. forceCompilationAsync(options?: Partial<{
  9692. useInstances: boolean;
  9693. }>): Promise<void>;
  9694. /**
  9695. * Serializes the shadow generator setup to a json object.
  9696. * @returns The serialized JSON object
  9697. */
  9698. serialize(): any;
  9699. /**
  9700. * Disposes the Shadow map and related Textures and effects.
  9701. */
  9702. dispose(): void;
  9703. }
  9704. /**
  9705. * Default implementation IShadowGenerator.
  9706. * This is the main object responsible of generating shadows in the framework.
  9707. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9708. */
  9709. export class ShadowGenerator implements IShadowGenerator {
  9710. /**
  9711. * Shadow generator mode None: no filtering applied.
  9712. */
  9713. static readonly FILTER_NONE: number;
  9714. /**
  9715. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9716. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9717. */
  9718. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9719. /**
  9720. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9721. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9722. */
  9723. static readonly FILTER_POISSONSAMPLING: number;
  9724. /**
  9725. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9727. */
  9728. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9729. /**
  9730. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9731. * edge artifacts on steep falloff.
  9732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9733. */
  9734. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9735. /**
  9736. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9737. * edge artifacts on steep falloff.
  9738. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9739. */
  9740. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9741. /**
  9742. * Shadow generator mode PCF: Percentage Closer Filtering
  9743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9744. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9745. */
  9746. static readonly FILTER_PCF: number;
  9747. /**
  9748. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9749. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9750. * Contact Hardening
  9751. */
  9752. static readonly FILTER_PCSS: number;
  9753. /**
  9754. * Reserved for PCF and PCSS
  9755. * Highest Quality.
  9756. *
  9757. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9758. *
  9759. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9760. */
  9761. static readonly QUALITY_HIGH: number;
  9762. /**
  9763. * Reserved for PCF and PCSS
  9764. * Good tradeoff for quality/perf cross devices
  9765. *
  9766. * Execute PCF on a 3*3 kernel.
  9767. *
  9768. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9769. */
  9770. static readonly QUALITY_MEDIUM: number;
  9771. /**
  9772. * Reserved for PCF and PCSS
  9773. * The lowest quality but the fastest.
  9774. *
  9775. * Execute PCF on a 1*1 kernel.
  9776. *
  9777. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9778. */
  9779. static readonly QUALITY_LOW: number;
  9780. /** Gets or sets the custom shader name to use */
  9781. customShaderOptions: ICustomShaderOptions;
  9782. /**
  9783. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9784. */
  9785. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9786. /**
  9787. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9788. */
  9789. onAfterShadowMapRenderObservable: Observable<Effect>;
  9790. /**
  9791. * Observable triggered before a mesh is rendered in the shadow map.
  9792. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9793. */
  9794. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9795. /**
  9796. * Observable triggered after a mesh is rendered in the shadow map.
  9797. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9798. */
  9799. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9800. private _bias;
  9801. /**
  9802. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9803. */
  9804. /**
  9805. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9806. */
  9807. bias: number;
  9808. private _normalBias;
  9809. /**
  9810. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9811. */
  9812. /**
  9813. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9814. */
  9815. normalBias: number;
  9816. private _blurBoxOffset;
  9817. /**
  9818. * Gets the blur box offset: offset applied during the blur pass.
  9819. * Only useful if useKernelBlur = false
  9820. */
  9821. /**
  9822. * Sets the blur box offset: offset applied during the blur pass.
  9823. * Only useful if useKernelBlur = false
  9824. */
  9825. blurBoxOffset: number;
  9826. private _blurScale;
  9827. /**
  9828. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9829. * 2 means half of the size.
  9830. */
  9831. /**
  9832. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9833. * 2 means half of the size.
  9834. */
  9835. blurScale: number;
  9836. private _blurKernel;
  9837. /**
  9838. * Gets the blur kernel: kernel size of the blur pass.
  9839. * Only useful if useKernelBlur = true
  9840. */
  9841. /**
  9842. * Sets the blur kernel: kernel size of the blur pass.
  9843. * Only useful if useKernelBlur = true
  9844. */
  9845. blurKernel: number;
  9846. private _useKernelBlur;
  9847. /**
  9848. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9849. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9850. */
  9851. /**
  9852. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9853. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9854. */
  9855. useKernelBlur: boolean;
  9856. private _depthScale;
  9857. /**
  9858. * Gets the depth scale used in ESM mode.
  9859. */
  9860. /**
  9861. * Sets the depth scale used in ESM mode.
  9862. * This can override the scale stored on the light.
  9863. */
  9864. depthScale: number;
  9865. private _filter;
  9866. /**
  9867. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9868. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9869. */
  9870. /**
  9871. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9872. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9873. */
  9874. filter: number;
  9875. /**
  9876. * Gets if the current filter is set to Poisson Sampling.
  9877. */
  9878. /**
  9879. * Sets the current filter to Poisson Sampling.
  9880. */
  9881. usePoissonSampling: boolean;
  9882. /**
  9883. * Gets if the current filter is set to ESM.
  9884. */
  9885. /**
  9886. * Sets the current filter is to ESM.
  9887. */
  9888. useExponentialShadowMap: boolean;
  9889. /**
  9890. * Gets if the current filter is set to filtered ESM.
  9891. */
  9892. /**
  9893. * Gets if the current filter is set to filtered ESM.
  9894. */
  9895. useBlurExponentialShadowMap: boolean;
  9896. /**
  9897. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9898. * exponential to prevent steep falloff artifacts).
  9899. */
  9900. /**
  9901. * Sets the current filter to "close ESM" (using the inverse of the
  9902. * exponential to prevent steep falloff artifacts).
  9903. */
  9904. useCloseExponentialShadowMap: boolean;
  9905. /**
  9906. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9907. * exponential to prevent steep falloff artifacts).
  9908. */
  9909. /**
  9910. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9911. * exponential to prevent steep falloff artifacts).
  9912. */
  9913. useBlurCloseExponentialShadowMap: boolean;
  9914. /**
  9915. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9916. */
  9917. /**
  9918. * Sets the current filter to "PCF" (percentage closer filtering).
  9919. */
  9920. usePercentageCloserFiltering: boolean;
  9921. private _filteringQuality;
  9922. /**
  9923. * Gets the PCF or PCSS Quality.
  9924. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9925. */
  9926. /**
  9927. * Sets the PCF or PCSS Quality.
  9928. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9929. */
  9930. filteringQuality: number;
  9931. /**
  9932. * Gets if the current filter is set to "PCSS" (contact hardening).
  9933. */
  9934. /**
  9935. * Sets the current filter to "PCSS" (contact hardening).
  9936. */
  9937. useContactHardeningShadow: boolean;
  9938. private _contactHardeningLightSizeUVRatio;
  9939. /**
  9940. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9941. * Using a ratio helps keeping shape stability independently of the map size.
  9942. *
  9943. * It does not account for the light projection as it was having too much
  9944. * instability during the light setup or during light position changes.
  9945. *
  9946. * Only valid if useContactHardeningShadow is true.
  9947. */
  9948. /**
  9949. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9950. * Using a ratio helps keeping shape stability independently of the map size.
  9951. *
  9952. * It does not account for the light projection as it was having too much
  9953. * instability during the light setup or during light position changes.
  9954. *
  9955. * Only valid if useContactHardeningShadow is true.
  9956. */
  9957. contactHardeningLightSizeUVRatio: number;
  9958. private _darkness;
  9959. /** Gets or sets the actual darkness of a shadow */
  9960. darkness: number;
  9961. /**
  9962. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9963. * 0 means strongest and 1 would means no shadow.
  9964. * @returns the darkness.
  9965. */
  9966. getDarkness(): number;
  9967. /**
  9968. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9969. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9970. * @returns the shadow generator allowing fluent coding.
  9971. */
  9972. setDarkness(darkness: number): ShadowGenerator;
  9973. private _transparencyShadow;
  9974. /** Gets or sets the ability to have transparent shadow */
  9975. transparencyShadow: boolean;
  9976. /**
  9977. * Sets the ability to have transparent shadow (boolean).
  9978. * @param transparent True if transparent else False
  9979. * @returns the shadow generator allowing fluent coding
  9980. */
  9981. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9982. private _shadowMap;
  9983. private _shadowMap2;
  9984. /**
  9985. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9986. * @returns The render target texture if present otherwise, null
  9987. */
  9988. getShadowMap(): Nullable<RenderTargetTexture>;
  9989. /**
  9990. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9991. * @returns The render target texture if the shadow map is present otherwise, null
  9992. */
  9993. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9994. /**
  9995. * Gets the class name of that object
  9996. * @returns "ShadowGenerator"
  9997. */
  9998. getClassName(): string;
  9999. /**
  10000. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10001. * @param mesh Mesh to add
  10002. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10003. * @returns the Shadow Generator itself
  10004. */
  10005. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10006. /**
  10007. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10008. * @param mesh Mesh to remove
  10009. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10010. * @returns the Shadow Generator itself
  10011. */
  10012. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10013. /**
  10014. * Controls the extent to which the shadows fade out at the edge of the frustum
  10015. * Used only by directionals and spots
  10016. */
  10017. frustumEdgeFalloff: number;
  10018. private _light;
  10019. /**
  10020. * Returns the associated light object.
  10021. * @returns the light generating the shadow
  10022. */
  10023. getLight(): IShadowLight;
  10024. /**
  10025. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10026. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10027. * It might on the other hand introduce peter panning.
  10028. */
  10029. forceBackFacesOnly: boolean;
  10030. private _scene;
  10031. private _lightDirection;
  10032. private _effect;
  10033. private _viewMatrix;
  10034. private _projectionMatrix;
  10035. private _transformMatrix;
  10036. private _cachedPosition;
  10037. private _cachedDirection;
  10038. private _cachedDefines;
  10039. private _currentRenderID;
  10040. private _boxBlurPostprocess;
  10041. private _kernelBlurXPostprocess;
  10042. private _kernelBlurYPostprocess;
  10043. private _blurPostProcesses;
  10044. private _mapSize;
  10045. private _currentFaceIndex;
  10046. private _currentFaceIndexCache;
  10047. private _textureType;
  10048. private _defaultTextureMatrix;
  10049. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  10050. /**
  10051. * Creates a ShadowGenerator object.
  10052. * A ShadowGenerator is the required tool to use the shadows.
  10053. * Each light casting shadows needs to use its own ShadowGenerator.
  10054. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10055. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10056. * @param light The light object generating the shadows.
  10057. * @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.
  10058. */
  10059. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10060. private _initializeGenerator;
  10061. private _initializeShadowMap;
  10062. private _initializeBlurRTTAndPostProcesses;
  10063. private _renderForShadowMap;
  10064. private _renderSubMeshForShadowMap;
  10065. private _applyFilterValues;
  10066. /**
  10067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10068. * @param onCompiled Callback triggered at the and of the effects compilation
  10069. * @param options Sets of optional options forcing the compilation with different modes
  10070. */
  10071. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10072. useInstances: boolean;
  10073. }>): void;
  10074. /**
  10075. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10076. * @param options Sets of optional options forcing the compilation with different modes
  10077. * @returns A promise that resolves when the compilation completes
  10078. */
  10079. forceCompilationAsync(options?: Partial<{
  10080. useInstances: boolean;
  10081. }>): Promise<void>;
  10082. /**
  10083. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10084. * @param subMesh The submesh we want to render in the shadow map
  10085. * @param useInstances Defines wether will draw in the map using instances
  10086. * @returns true if ready otherwise, false
  10087. */
  10088. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10089. /**
  10090. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10091. * @param defines Defines of the material we want to update
  10092. * @param lightIndex Index of the light in the enabled light list of the material
  10093. */
  10094. prepareDefines(defines: any, lightIndex: number): void;
  10095. /**
  10096. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10097. * defined in the generator but impacting the effect).
  10098. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10099. * @param effect The effect we are binfing the information for
  10100. */
  10101. bindShadowLight(lightIndex: string, effect: Effect): void;
  10102. /**
  10103. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10104. * (eq to shadow prjection matrix * light transform matrix)
  10105. * @returns The transform matrix used to create the shadow map
  10106. */
  10107. getTransformMatrix(): Matrix;
  10108. /**
  10109. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10110. * Cube and 2D textures for instance.
  10111. */
  10112. recreateShadowMap(): void;
  10113. private _disposeBlurPostProcesses;
  10114. private _disposeRTTandPostProcesses;
  10115. /**
  10116. * Disposes the ShadowGenerator.
  10117. * Returns nothing.
  10118. */
  10119. dispose(): void;
  10120. /**
  10121. * Serializes the shadow generator setup to a json object.
  10122. * @returns The serialized JSON object
  10123. */
  10124. serialize(): any;
  10125. /**
  10126. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10127. * @param parsedShadowGenerator The JSON object to parse
  10128. * @param scene The scene to create the shadow map for
  10129. * @returns The parsed shadow generator
  10130. */
  10131. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10132. }
  10133. }
  10134. declare module BABYLON {
  10135. /**
  10136. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10137. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10138. * 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.
  10139. */
  10140. export abstract class Light extends Node {
  10141. /**
  10142. * Falloff Default: light is falling off following the material specification:
  10143. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10144. */
  10145. static readonly FALLOFF_DEFAULT: number;
  10146. /**
  10147. * Falloff Physical: light is falling off following the inverse squared distance law.
  10148. */
  10149. static readonly FALLOFF_PHYSICAL: number;
  10150. /**
  10151. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10152. * to enhance interoperability with other engines.
  10153. */
  10154. static readonly FALLOFF_GLTF: number;
  10155. /**
  10156. * Falloff Standard: light is falling off like in the standard material
  10157. * to enhance interoperability with other materials.
  10158. */
  10159. static readonly FALLOFF_STANDARD: number;
  10160. /**
  10161. * If every light affecting the material is in this lightmapMode,
  10162. * material.lightmapTexture adds or multiplies
  10163. * (depends on material.useLightmapAsShadowmap)
  10164. * after every other light calculations.
  10165. */
  10166. static readonly LIGHTMAP_DEFAULT: number;
  10167. /**
  10168. * material.lightmapTexture as only diffuse lighting from this light
  10169. * adds only specular lighting from this light
  10170. * adds dynamic shadows
  10171. */
  10172. static readonly LIGHTMAP_SPECULAR: number;
  10173. /**
  10174. * material.lightmapTexture as only lighting
  10175. * no light calculation from this light
  10176. * only adds dynamic shadows from this light
  10177. */
  10178. static readonly LIGHTMAP_SHADOWSONLY: number;
  10179. /**
  10180. * Each light type uses the default quantity according to its type:
  10181. * point/spot lights use luminous intensity
  10182. * directional lights use illuminance
  10183. */
  10184. static readonly INTENSITYMODE_AUTOMATIC: number;
  10185. /**
  10186. * lumen (lm)
  10187. */
  10188. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10189. /**
  10190. * candela (lm/sr)
  10191. */
  10192. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10193. /**
  10194. * lux (lm/m^2)
  10195. */
  10196. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10197. /**
  10198. * nit (cd/m^2)
  10199. */
  10200. static readonly INTENSITYMODE_LUMINANCE: number;
  10201. /**
  10202. * Light type const id of the point light.
  10203. */
  10204. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10205. /**
  10206. * Light type const id of the directional light.
  10207. */
  10208. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10209. /**
  10210. * Light type const id of the spot light.
  10211. */
  10212. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10213. /**
  10214. * Light type const id of the hemispheric light.
  10215. */
  10216. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10217. /**
  10218. * Diffuse gives the basic color to an object.
  10219. */
  10220. diffuse: Color3;
  10221. /**
  10222. * Specular produces a highlight color on an object.
  10223. * Note: This is note affecting PBR materials.
  10224. */
  10225. specular: Color3;
  10226. /**
  10227. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10228. * falling off base on range or angle.
  10229. * This can be set to any values in Light.FALLOFF_x.
  10230. *
  10231. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10232. * other types of materials.
  10233. */
  10234. falloffType: number;
  10235. /**
  10236. * Strength of the light.
  10237. * Note: By default it is define in the framework own unit.
  10238. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10239. */
  10240. intensity: number;
  10241. private _range;
  10242. protected _inverseSquaredRange: number;
  10243. /**
  10244. * Defines how far from the source the light is impacting in scene units.
  10245. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10246. */
  10247. /**
  10248. * Defines how far from the source the light is impacting in scene units.
  10249. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10250. */
  10251. range: number;
  10252. /**
  10253. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10254. * of light.
  10255. */
  10256. private _photometricScale;
  10257. private _intensityMode;
  10258. /**
  10259. * Gets the photometric scale used to interpret the intensity.
  10260. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10261. */
  10262. /**
  10263. * Sets the photometric scale used to interpret the intensity.
  10264. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10265. */
  10266. intensityMode: number;
  10267. private _radius;
  10268. /**
  10269. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10270. */
  10271. /**
  10272. * sets the light radius used by PBR Materials to simulate soft area lights.
  10273. */
  10274. radius: number;
  10275. private _renderPriority;
  10276. /**
  10277. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10278. * exceeding the number allowed of the materials.
  10279. */
  10280. renderPriority: number;
  10281. private _shadowEnabled;
  10282. /**
  10283. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10284. * the current shadow generator.
  10285. */
  10286. /**
  10287. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10288. * the current shadow generator.
  10289. */
  10290. shadowEnabled: boolean;
  10291. private _includedOnlyMeshes;
  10292. /**
  10293. * Gets the only meshes impacted by this light.
  10294. */
  10295. /**
  10296. * Sets the only meshes impacted by this light.
  10297. */
  10298. includedOnlyMeshes: AbstractMesh[];
  10299. private _excludedMeshes;
  10300. /**
  10301. * Gets the meshes not impacted by this light.
  10302. */
  10303. /**
  10304. * Sets the meshes not impacted by this light.
  10305. */
  10306. excludedMeshes: AbstractMesh[];
  10307. private _excludeWithLayerMask;
  10308. /**
  10309. * Gets the layer id use to find what meshes are not impacted by the light.
  10310. * Inactive if 0
  10311. */
  10312. /**
  10313. * Sets the layer id use to find what meshes are not impacted by the light.
  10314. * Inactive if 0
  10315. */
  10316. excludeWithLayerMask: number;
  10317. private _includeOnlyWithLayerMask;
  10318. /**
  10319. * Gets the layer id use to find what meshes are impacted by the light.
  10320. * Inactive if 0
  10321. */
  10322. /**
  10323. * Sets the layer id use to find what meshes are impacted by the light.
  10324. * Inactive if 0
  10325. */
  10326. includeOnlyWithLayerMask: number;
  10327. private _lightmapMode;
  10328. /**
  10329. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10330. */
  10331. /**
  10332. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10333. */
  10334. lightmapMode: number;
  10335. /**
  10336. * Shadow generator associted to the light.
  10337. * @hidden Internal use only.
  10338. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  10339. /**
  10340. * @hidden Internal use only.
  10341. */ private _excludedMeshesIds: string[];
  10342. /**
  10343. * @hidden Internal use only.
  10344. */ private _includedOnlyMeshesIds: string[];
  10345. /**
  10346. * The current light unifom buffer.
  10347. * @hidden Internal use only.
  10348. */ private _uniformBuffer: UniformBuffer;
  10349. /**
  10350. * Creates a Light object in the scene.
  10351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10352. * @param name The firendly name of the light
  10353. * @param scene The scene the light belongs too
  10354. */
  10355. constructor(name: string, scene: Scene);
  10356. protected abstract _buildUniformLayout(): void;
  10357. /**
  10358. * Sets the passed Effect "effect" with the Light information.
  10359. * @param effect The effect to update
  10360. * @param lightIndex The index of the light in the effect to update
  10361. * @returns The light
  10362. */
  10363. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10364. /**
  10365. * Returns the string "Light".
  10366. * @returns the class name
  10367. */
  10368. getClassName(): string;
  10369. /** @hidden */ protected readonly _isLight: boolean;
  10370. /**
  10371. * Converts the light information to a readable string for debug purpose.
  10372. * @param fullDetails Supports for multiple levels of logging within scene loading
  10373. * @returns the human readable light info
  10374. */
  10375. toString(fullDetails?: boolean): string;
  10376. /** @hidden */
  10377. protected _syncParentEnabledState(): void;
  10378. /**
  10379. * Set the enabled state of this node.
  10380. * @param value - the new enabled state
  10381. */
  10382. setEnabled(value: boolean): void;
  10383. /**
  10384. * Returns the Light associated shadow generator if any.
  10385. * @return the associated shadow generator.
  10386. */
  10387. getShadowGenerator(): Nullable<IShadowGenerator>;
  10388. /**
  10389. * Returns a Vector3, the absolute light position in the World.
  10390. * @returns the world space position of the light
  10391. */
  10392. getAbsolutePosition(): Vector3;
  10393. /**
  10394. * Specifies if the light will affect the passed mesh.
  10395. * @param mesh The mesh to test against the light
  10396. * @return true the mesh is affected otherwise, false.
  10397. */
  10398. canAffectMesh(mesh: AbstractMesh): boolean;
  10399. /**
  10400. * Sort function to order lights for rendering.
  10401. * @param a First Light object to compare to second.
  10402. * @param b Second Light object to compare first.
  10403. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10404. */
  10405. static CompareLightsPriority(a: Light, b: Light): number;
  10406. /**
  10407. * Releases resources associated with this node.
  10408. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10409. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10410. */
  10411. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10412. /**
  10413. * Returns the light type ID (integer).
  10414. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10415. */
  10416. getTypeID(): number;
  10417. /**
  10418. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10419. * @returns the scaled intensity in intensity mode unit
  10420. */
  10421. getScaledIntensity(): number;
  10422. /**
  10423. * Returns a new Light object, named "name", from the current one.
  10424. * @param name The name of the cloned light
  10425. * @returns the new created light
  10426. */
  10427. clone(name: string): Nullable<Light>;
  10428. /**
  10429. * Serializes the current light into a Serialization object.
  10430. * @returns the serialized object.
  10431. */
  10432. serialize(): any;
  10433. /**
  10434. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10435. * This new light is named "name" and added to the passed scene.
  10436. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10437. * @param name The friendly name of the light
  10438. * @param scene The scene the new light will belong to
  10439. * @returns the constructor function
  10440. */
  10441. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10442. /**
  10443. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10444. * @param parsedLight The JSON representation of the light
  10445. * @param scene The scene to create the parsed light in
  10446. * @returns the created light after parsing
  10447. */
  10448. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10449. private _hookArrayForExcluded;
  10450. private _hookArrayForIncludedOnly;
  10451. private _resyncMeshes;
  10452. /**
  10453. * Forces the meshes to update their light related information in their rendering used effects
  10454. * @hidden Internal Use Only
  10455. */ private _markMeshesAsLightDirty(): void;
  10456. /**
  10457. * Recomputes the cached photometric scale if needed.
  10458. */
  10459. private _computePhotometricScale;
  10460. /**
  10461. * Returns the Photometric Scale according to the light type and intensity mode.
  10462. */
  10463. private _getPhotometricScale;
  10464. /**
  10465. * Reorder the light in the scene according to their defined priority.
  10466. * @hidden Internal Use Only
  10467. */ private _reorderLightsInScene(): void;
  10468. /**
  10469. * Prepares the list of defines specific to the light type.
  10470. * @param defines the list of defines
  10471. * @param lightIndex defines the index of the light for the effect
  10472. */
  10473. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10474. }
  10475. }
  10476. declare module BABYLON {
  10477. /**
  10478. * Interface used to define Action
  10479. */
  10480. export interface IAction {
  10481. /**
  10482. * Trigger for the action
  10483. */
  10484. trigger: number;
  10485. /** Options of the trigger */
  10486. triggerOptions: any;
  10487. /**
  10488. * Gets the trigger parameters
  10489. * @returns the trigger parameters
  10490. */
  10491. getTriggerParameter(): any;
  10492. /**
  10493. * Internal only - executes current action event
  10494. * @hidden
  10495. */ private _executeCurrent(evt?: ActionEvent): void;
  10496. /**
  10497. * Serialize placeholder for child classes
  10498. * @param parent of child
  10499. * @returns the serialized object
  10500. */
  10501. serialize(parent: any): any;
  10502. /**
  10503. * Internal only
  10504. * @hidden
  10505. */ private _prepare(): void;
  10506. /**
  10507. * Internal only - manager for action
  10508. * @hidden
  10509. */ private _actionManager: AbstractActionManager;
  10510. /**
  10511. * Adds action to chain of actions, may be a DoNothingAction
  10512. * @param action defines the next action to execute
  10513. * @returns The action passed in
  10514. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10515. */
  10516. then(action: IAction): IAction;
  10517. }
  10518. /**
  10519. * The action to be carried out following a trigger
  10520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10521. */
  10522. export class Action implements IAction {
  10523. /** the trigger, with or without parameters, for the action */
  10524. triggerOptions: any;
  10525. /**
  10526. * Trigger for the action
  10527. */
  10528. trigger: number;
  10529. /**
  10530. * Internal only - manager for action
  10531. * @hidden
  10532. */ private _actionManager: ActionManager;
  10533. private _nextActiveAction;
  10534. private _child;
  10535. private _condition?;
  10536. private _triggerParameter;
  10537. /**
  10538. * An event triggered prior to action being executed.
  10539. */
  10540. onBeforeExecuteObservable: Observable<Action>;
  10541. /**
  10542. * Creates a new Action
  10543. * @param triggerOptions the trigger, with or without parameters, for the action
  10544. * @param condition an optional determinant of action
  10545. */
  10546. constructor(
  10547. /** the trigger, with or without parameters, for the action */
  10548. triggerOptions: any, condition?: Condition);
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */ private _prepare(): void;
  10553. /**
  10554. * Gets the trigger parameters
  10555. * @returns the trigger parameters
  10556. */
  10557. getTriggerParameter(): any;
  10558. /**
  10559. * Internal only - executes current action event
  10560. * @hidden
  10561. */ private _executeCurrent(evt?: ActionEvent): void;
  10562. /**
  10563. * Execute placeholder for child classes
  10564. * @param evt optional action event
  10565. */
  10566. execute(evt?: ActionEvent): void;
  10567. /**
  10568. * Skips to next active action
  10569. */
  10570. skipToNextActiveAction(): void;
  10571. /**
  10572. * Adds action to chain of actions, may be a DoNothingAction
  10573. * @param action defines the next action to execute
  10574. * @returns The action passed in
  10575. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10576. */
  10577. then(action: Action): Action;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */ private _getProperty(propertyPath: string): string;
  10582. /**
  10583. * Internal only
  10584. * @hidden
  10585. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10586. /**
  10587. * Serialize placeholder for child classes
  10588. * @param parent of child
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. /**
  10593. * Internal only called by serialize
  10594. * @hidden
  10595. */
  10596. protected _serialize(serializedAction: any, parent?: any): any;
  10597. /**
  10598. * Internal only
  10599. * @hidden
  10600. */ private static _SerializeValueAsString: (value: any) => string;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10605. name: string;
  10606. targetType: string;
  10607. value: string;
  10608. };
  10609. }
  10610. }
  10611. declare module BABYLON {
  10612. /**
  10613. * A Condition applied to an Action
  10614. */
  10615. export class Condition {
  10616. /**
  10617. * Internal only - manager for action
  10618. * @hidden
  10619. */ private _actionManager: ActionManager;
  10620. /**
  10621. * Internal only
  10622. * @hidden
  10623. */ private _evaluationId: number;
  10624. /**
  10625. * Internal only
  10626. * @hidden
  10627. */ private _currentResult: boolean;
  10628. /**
  10629. * Creates a new Condition
  10630. * @param actionManager the manager of the action the condition is applied to
  10631. */
  10632. constructor(actionManager: ActionManager);
  10633. /**
  10634. * Check if the current condition is valid
  10635. * @returns a boolean
  10636. */
  10637. isValid(): boolean;
  10638. /**
  10639. * Internal only
  10640. * @hidden
  10641. */ private _getProperty(propertyPath: string): string;
  10642. /**
  10643. * Internal only
  10644. * @hidden
  10645. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10646. /**
  10647. * Serialize placeholder for child classes
  10648. * @returns the serialized object
  10649. */
  10650. serialize(): any;
  10651. /**
  10652. * Internal only
  10653. * @hidden
  10654. */
  10655. protected _serialize(serializedCondition: any): any;
  10656. }
  10657. /**
  10658. * Defines specific conditional operators as extensions of Condition
  10659. */
  10660. export class ValueCondition extends Condition {
  10661. /** path to specify the property of the target the conditional operator uses */
  10662. propertyPath: string;
  10663. /** the value compared by the conditional operator against the current value of the property */
  10664. value: any;
  10665. /** the conditional operator, default ValueCondition.IsEqual */
  10666. operator: number;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. private static _IsEqual;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. private static _IsDifferent;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private static _IsGreater;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private static _IsLesser;
  10687. /**
  10688. * returns the number for IsEqual
  10689. */
  10690. static readonly IsEqual: number;
  10691. /**
  10692. * Returns the number for IsDifferent
  10693. */
  10694. static readonly IsDifferent: number;
  10695. /**
  10696. * Returns the number for IsGreater
  10697. */
  10698. static readonly IsGreater: number;
  10699. /**
  10700. * Returns the number for IsLesser
  10701. */
  10702. static readonly IsLesser: number;
  10703. /**
  10704. * Internal only The action manager for the condition
  10705. * @hidden
  10706. */ private _actionManager: ActionManager;
  10707. /**
  10708. * Internal only
  10709. * @hidden
  10710. */
  10711. private _target;
  10712. /**
  10713. * Internal only
  10714. * @hidden
  10715. */
  10716. private _effectiveTarget;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. private _property;
  10722. /**
  10723. * Creates a new ValueCondition
  10724. * @param actionManager manager for the action the condition applies to
  10725. * @param target for the action
  10726. * @param propertyPath path to specify the property of the target the conditional operator uses
  10727. * @param value the value compared by the conditional operator against the current value of the property
  10728. * @param operator the conditional operator, default ValueCondition.IsEqual
  10729. */
  10730. constructor(actionManager: ActionManager, target: any,
  10731. /** path to specify the property of the target the conditional operator uses */
  10732. propertyPath: string,
  10733. /** the value compared by the conditional operator against the current value of the property */
  10734. value: any,
  10735. /** the conditional operator, default ValueCondition.IsEqual */
  10736. operator?: number);
  10737. /**
  10738. * Compares the given value with the property value for the specified conditional operator
  10739. * @returns the result of the comparison
  10740. */
  10741. isValid(): boolean;
  10742. /**
  10743. * Serialize the ValueCondition into a JSON compatible object
  10744. * @returns serialization object
  10745. */
  10746. serialize(): any;
  10747. /**
  10748. * Gets the name of the conditional operator for the ValueCondition
  10749. * @param operator the conditional operator
  10750. * @returns the name
  10751. */
  10752. static GetOperatorName(operator: number): string;
  10753. }
  10754. /**
  10755. * Defines a predicate condition as an extension of Condition
  10756. */
  10757. export class PredicateCondition extends Condition {
  10758. /** defines the predicate function used to validate the condition */
  10759. predicate: () => boolean;
  10760. /**
  10761. * Internal only - manager for action
  10762. * @hidden
  10763. */ private _actionManager: ActionManager;
  10764. /**
  10765. * Creates a new PredicateCondition
  10766. * @param actionManager manager for the action the condition applies to
  10767. * @param predicate defines the predicate function used to validate the condition
  10768. */
  10769. constructor(actionManager: ActionManager,
  10770. /** defines the predicate function used to validate the condition */
  10771. predicate: () => boolean);
  10772. /**
  10773. * @returns the validity of the predicate condition
  10774. */
  10775. isValid(): boolean;
  10776. }
  10777. /**
  10778. * Defines a state condition as an extension of Condition
  10779. */
  10780. export class StateCondition extends Condition {
  10781. /** Value to compare with target state */
  10782. value: string;
  10783. /**
  10784. * Internal only - manager for action
  10785. * @hidden
  10786. */ private _actionManager: ActionManager;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. private _target;
  10792. /**
  10793. * Creates a new StateCondition
  10794. * @param actionManager manager for the action the condition applies to
  10795. * @param target of the condition
  10796. * @param value to compare with target state
  10797. */
  10798. constructor(actionManager: ActionManager, target: any,
  10799. /** Value to compare with target state */
  10800. value: string);
  10801. /**
  10802. * Gets a boolean indicating if the current condition is met
  10803. * @returns the validity of the state
  10804. */
  10805. isValid(): boolean;
  10806. /**
  10807. * Serialize the StateCondition into a JSON compatible object
  10808. * @returns serialization object
  10809. */
  10810. serialize(): any;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * This defines an action responsible to toggle a boolean once triggered.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class SwitchBooleanAction extends Action {
  10819. /**
  10820. * The path to the boolean property in the target object
  10821. */
  10822. propertyPath: string;
  10823. private _target;
  10824. private _effectiveTarget;
  10825. private _property;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the object containing the boolean
  10830. * @param propertyPath defines the path to the boolean property in the target object
  10831. * @param condition defines the trigger related conditions
  10832. */
  10833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10834. /** @hidden */ private _prepare(): void;
  10835. /**
  10836. * Execute the action toggle the boolean value.
  10837. */
  10838. execute(): void;
  10839. /**
  10840. * Serializes the actions and its related information.
  10841. * @param parent defines the object to serialize in
  10842. * @returns the serialized object
  10843. */
  10844. serialize(parent: any): any;
  10845. }
  10846. /**
  10847. * This defines an action responsible to set a the state field of the target
  10848. * to a desired value once triggered.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class SetStateAction extends Action {
  10852. /**
  10853. * The value to store in the state field.
  10854. */
  10855. value: string;
  10856. private _target;
  10857. /**
  10858. * Instantiate the action
  10859. * @param triggerOptions defines the trigger options
  10860. * @param target defines the object containing the state property
  10861. * @param value defines the value to store in the state field
  10862. * @param condition defines the trigger related conditions
  10863. */
  10864. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10865. /**
  10866. * Execute the action and store the value on the target state property.
  10867. */
  10868. execute(): void;
  10869. /**
  10870. * Serializes the actions and its related information.
  10871. * @param parent defines the object to serialize in
  10872. * @returns the serialized object
  10873. */
  10874. serialize(parent: any): any;
  10875. }
  10876. /**
  10877. * This defines an action responsible to set a property of the target
  10878. * to a desired value once triggered.
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10880. */
  10881. export class SetValueAction extends Action {
  10882. /**
  10883. * The path of the property to set in the target.
  10884. */
  10885. propertyPath: string;
  10886. /**
  10887. * The value to set in the property
  10888. */
  10889. value: any;
  10890. private _target;
  10891. private _effectiveTarget;
  10892. private _property;
  10893. /**
  10894. * Instantiate the action
  10895. * @param triggerOptions defines the trigger options
  10896. * @param target defines the object containing the property
  10897. * @param propertyPath defines the path of the property to set in the target
  10898. * @param value defines the value to set in the property
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10902. /** @hidden */ private _prepare(): void;
  10903. /**
  10904. * Execute the action and set the targetted property to the desired value.
  10905. */
  10906. execute(): void;
  10907. /**
  10908. * Serializes the actions and its related information.
  10909. * @param parent defines the object to serialize in
  10910. * @returns the serialized object
  10911. */
  10912. serialize(parent: any): any;
  10913. }
  10914. /**
  10915. * This defines an action responsible to increment the target value
  10916. * to a desired value once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class IncrementValueAction extends Action {
  10920. /**
  10921. * The path of the property to increment in the target.
  10922. */
  10923. propertyPath: string;
  10924. /**
  10925. * The value we should increment the property by.
  10926. */
  10927. value: any;
  10928. private _target;
  10929. private _effectiveTarget;
  10930. private _property;
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param target defines the object containing the property
  10935. * @param propertyPath defines the path of the property to increment in the target
  10936. * @param value defines the value value we should increment the property by
  10937. * @param condition defines the trigger related conditions
  10938. */
  10939. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10940. /** @hidden */ private _prepare(): void;
  10941. /**
  10942. * Execute the action and increment the target of the value amount.
  10943. */
  10944. execute(): void;
  10945. /**
  10946. * Serializes the actions and its related information.
  10947. * @param parent defines the object to serialize in
  10948. * @returns the serialized object
  10949. */
  10950. serialize(parent: any): any;
  10951. }
  10952. /**
  10953. * This defines an action responsible to start an animation once triggered.
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10955. */
  10956. export class PlayAnimationAction extends Action {
  10957. /**
  10958. * Where the animation should start (animation frame)
  10959. */
  10960. from: number;
  10961. /**
  10962. * Where the animation should stop (animation frame)
  10963. */
  10964. to: number;
  10965. /**
  10966. * Define if the animation should loop or stop after the first play.
  10967. */
  10968. loop?: boolean;
  10969. private _target;
  10970. /**
  10971. * Instantiate the action
  10972. * @param triggerOptions defines the trigger options
  10973. * @param target defines the target animation or animation name
  10974. * @param from defines from where the animation should start (animation frame)
  10975. * @param end defines where the animation should stop (animation frame)
  10976. * @param loop defines if the animation should loop or stop after the first play
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10980. /** @hidden */ private _prepare(): void;
  10981. /**
  10982. * Execute the action and play the animation.
  10983. */
  10984. execute(): void;
  10985. /**
  10986. * Serializes the actions and its related information.
  10987. * @param parent defines the object to serialize in
  10988. * @returns the serialized object
  10989. */
  10990. serialize(parent: any): any;
  10991. }
  10992. /**
  10993. * This defines an action responsible to stop an animation once triggered.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class StopAnimationAction extends Action {
  10997. private _target;
  10998. /**
  10999. * Instantiate the action
  11000. * @param triggerOptions defines the trigger options
  11001. * @param target defines the target animation or animation name
  11002. * @param condition defines the trigger related conditions
  11003. */
  11004. constructor(triggerOptions: any, target: any, condition?: Condition);
  11005. /** @hidden */ private _prepare(): void;
  11006. /**
  11007. * Execute the action and stop the animation.
  11008. */
  11009. execute(): void;
  11010. /**
  11011. * Serializes the actions and its related information.
  11012. * @param parent defines the object to serialize in
  11013. * @returns the serialized object
  11014. */
  11015. serialize(parent: any): any;
  11016. }
  11017. /**
  11018. * This defines an action responsible that does nothing once triggered.
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11020. */
  11021. export class DoNothingAction extends Action {
  11022. /**
  11023. * Instantiate the action
  11024. * @param triggerOptions defines the trigger options
  11025. * @param condition defines the trigger related conditions
  11026. */
  11027. constructor(triggerOptions?: any, condition?: Condition);
  11028. /**
  11029. * Execute the action and do nothing.
  11030. */
  11031. execute(): void;
  11032. /**
  11033. * Serializes the actions and its related information.
  11034. * @param parent defines the object to serialize in
  11035. * @returns the serialized object
  11036. */
  11037. serialize(parent: any): any;
  11038. }
  11039. /**
  11040. * This defines an action responsible to trigger several actions once triggered.
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11042. */
  11043. export class CombineAction extends Action {
  11044. /**
  11045. * The list of aggregated animations to run.
  11046. */
  11047. children: Action[];
  11048. /**
  11049. * Instantiate the action
  11050. * @param triggerOptions defines the trigger options
  11051. * @param children defines the list of aggregated animations to run
  11052. * @param condition defines the trigger related conditions
  11053. */
  11054. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11055. /** @hidden */ private _prepare(): void;
  11056. /**
  11057. * Execute the action and executes all the aggregated actions.
  11058. */
  11059. execute(evt: ActionEvent): void;
  11060. /**
  11061. * Serializes the actions and its related information.
  11062. * @param parent defines the object to serialize in
  11063. * @returns the serialized object
  11064. */
  11065. serialize(parent: any): any;
  11066. }
  11067. /**
  11068. * This defines an action responsible to run code (external event) once triggered.
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11070. */
  11071. export class ExecuteCodeAction extends Action {
  11072. /**
  11073. * The callback function to run.
  11074. */
  11075. func: (evt: ActionEvent) => void;
  11076. /**
  11077. * Instantiate the action
  11078. * @param triggerOptions defines the trigger options
  11079. * @param func defines the callback function to run
  11080. * @param condition defines the trigger related conditions
  11081. */
  11082. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11083. /**
  11084. * Execute the action and run the attached code.
  11085. */
  11086. execute(evt: ActionEvent): void;
  11087. }
  11088. /**
  11089. * This defines an action responsible to set the parent property of the target once triggered.
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11091. */
  11092. export class SetParentAction extends Action {
  11093. private _parent;
  11094. private _target;
  11095. /**
  11096. * Instantiate the action
  11097. * @param triggerOptions defines the trigger options
  11098. * @param target defines the target containing the parent property
  11099. * @param parent defines from where the animation should start (animation frame)
  11100. * @param condition defines the trigger related conditions
  11101. */
  11102. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11103. /** @hidden */ private _prepare(): void;
  11104. /**
  11105. * Execute the action and set the parent property.
  11106. */
  11107. execute(): void;
  11108. /**
  11109. * Serializes the actions and its related information.
  11110. * @param parent defines the object to serialize in
  11111. * @returns the serialized object
  11112. */
  11113. serialize(parent: any): any;
  11114. }
  11115. }
  11116. declare module BABYLON {
  11117. /**
  11118. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11119. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11121. */
  11122. export class ActionManager extends AbstractActionManager {
  11123. /**
  11124. * Nothing
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11126. */
  11127. static readonly NothingTrigger: number;
  11128. /**
  11129. * On pick
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11131. */
  11132. static readonly OnPickTrigger: number;
  11133. /**
  11134. * On left pick
  11135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11136. */
  11137. static readonly OnLeftPickTrigger: number;
  11138. /**
  11139. * On right pick
  11140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11141. */
  11142. static readonly OnRightPickTrigger: number;
  11143. /**
  11144. * On center pick
  11145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11146. */
  11147. static readonly OnCenterPickTrigger: number;
  11148. /**
  11149. * On pick down
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11151. */
  11152. static readonly OnPickDownTrigger: number;
  11153. /**
  11154. * On double pick
  11155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11156. */
  11157. static readonly OnDoublePickTrigger: number;
  11158. /**
  11159. * On pick up
  11160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11161. */
  11162. static readonly OnPickUpTrigger: number;
  11163. /**
  11164. * On pick out.
  11165. * This trigger will only be raised if you also declared a OnPickDown
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11167. */
  11168. static readonly OnPickOutTrigger: number;
  11169. /**
  11170. * On long press
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnLongPressTrigger: number;
  11174. /**
  11175. * On pointer over
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnPointerOverTrigger: number;
  11179. /**
  11180. * On pointer out
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPointerOutTrigger: number;
  11184. /**
  11185. * On every frame
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnEveryFrameTrigger: number;
  11189. /**
  11190. * On intersection enter
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnIntersectionEnterTrigger: number;
  11194. /**
  11195. * On intersection exit
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnIntersectionExitTrigger: number;
  11199. /**
  11200. * On key down
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnKeyDownTrigger: number;
  11204. /**
  11205. * On key up
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnKeyUpTrigger: number;
  11209. private _scene;
  11210. /**
  11211. * Creates a new action manager
  11212. * @param scene defines the hosting scene
  11213. */
  11214. constructor(scene: Scene);
  11215. /**
  11216. * Releases all associated resources
  11217. */
  11218. dispose(): void;
  11219. /**
  11220. * Gets hosting scene
  11221. * @returns the hosting scene
  11222. */
  11223. getScene(): Scene;
  11224. /**
  11225. * Does this action manager handles actions of any of the given triggers
  11226. * @param triggers defines the triggers to be tested
  11227. * @return a boolean indicating whether one (or more) of the triggers is handled
  11228. */
  11229. hasSpecificTriggers(triggers: number[]): boolean;
  11230. /**
  11231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11232. * speed.
  11233. * @param triggerA defines the trigger to be tested
  11234. * @param triggerB defines the trigger to be tested
  11235. * @return a boolean indicating whether one (or more) of the triggers is handled
  11236. */
  11237. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11238. /**
  11239. * Does this action manager handles actions of a given trigger
  11240. * @param trigger defines the trigger to be tested
  11241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11242. * @return whether the trigger is handled
  11243. */
  11244. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11245. /**
  11246. * Does this action manager has pointer triggers
  11247. */
  11248. readonly hasPointerTriggers: boolean;
  11249. /**
  11250. * Does this action manager has pick triggers
  11251. */
  11252. readonly hasPickTriggers: boolean;
  11253. /**
  11254. * Registers an action to this action manager
  11255. * @param action defines the action to be registered
  11256. * @return the action amended (prepared) after registration
  11257. */
  11258. registerAction(action: IAction): Nullable<IAction>;
  11259. /**
  11260. * Unregisters an action to this action manager
  11261. * @param action defines the action to be unregistered
  11262. * @return a boolean indicating whether the action has been unregistered
  11263. */
  11264. unregisterAction(action: IAction): Boolean;
  11265. /**
  11266. * Process a specific trigger
  11267. * @param trigger defines the trigger to process
  11268. * @param evt defines the event details to be processed
  11269. */
  11270. processTrigger(trigger: number, evt?: IActionEvent): void;
  11271. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  11272. /** @hidden */ private _getProperty(propertyPath: string): string;
  11273. /**
  11274. * Serialize this manager to a JSON object
  11275. * @param name defines the property name to store this manager
  11276. * @returns a JSON representation of this manager
  11277. */
  11278. serialize(name: string): any;
  11279. /**
  11280. * Creates a new ActionManager from a JSON data
  11281. * @param parsedActions defines the JSON data to read from
  11282. * @param object defines the hosting mesh
  11283. * @param scene defines the hosting scene
  11284. */
  11285. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11286. /**
  11287. * Get a trigger name by index
  11288. * @param trigger defines the trigger index
  11289. * @returns a trigger name
  11290. */
  11291. static GetTriggerName(trigger: number): string;
  11292. }
  11293. }
  11294. declare module BABYLON {
  11295. /**
  11296. * Class representing a ray with position and direction
  11297. */
  11298. export class Ray {
  11299. /** origin point */
  11300. origin: Vector3;
  11301. /** direction */
  11302. direction: Vector3;
  11303. /** length of the ray */
  11304. length: number;
  11305. private static readonly TmpVector3;
  11306. private _tmpRay;
  11307. /**
  11308. * Creates a new ray
  11309. * @param origin origin point
  11310. * @param direction direction
  11311. * @param length length of the ray
  11312. */
  11313. constructor(
  11314. /** origin point */
  11315. origin: Vector3,
  11316. /** direction */
  11317. direction: Vector3,
  11318. /** length of the ray */
  11319. length?: number);
  11320. /**
  11321. * Checks if the ray intersects a box
  11322. * @param minimum bound of the box
  11323. * @param maximum bound of the box
  11324. * @param intersectionTreshold extra extend to be added to the box in all direction
  11325. * @returns if the box was hit
  11326. */
  11327. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11328. /**
  11329. * Checks if the ray intersects a box
  11330. * @param box the bounding box to check
  11331. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11332. * @returns if the box was hit
  11333. */
  11334. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11335. /**
  11336. * If the ray hits a sphere
  11337. * @param sphere the bounding sphere to check
  11338. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11339. * @returns true if it hits the sphere
  11340. */
  11341. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11342. /**
  11343. * If the ray hits a triange
  11344. * @param vertex0 triangle vertex
  11345. * @param vertex1 triangle vertex
  11346. * @param vertex2 triangle vertex
  11347. * @returns intersection information if hit
  11348. */
  11349. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11350. /**
  11351. * Checks if ray intersects a plane
  11352. * @param plane the plane to check
  11353. * @returns the distance away it was hit
  11354. */
  11355. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11356. /**
  11357. * Checks if ray intersects a mesh
  11358. * @param mesh the mesh to check
  11359. * @param fastCheck if only the bounding box should checked
  11360. * @returns picking info of the intersecton
  11361. */
  11362. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11363. /**
  11364. * Checks if ray intersects a mesh
  11365. * @param meshes the meshes to check
  11366. * @param fastCheck if only the bounding box should checked
  11367. * @param results array to store result in
  11368. * @returns Array of picking infos
  11369. */
  11370. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11371. private _comparePickingInfo;
  11372. private static smallnum;
  11373. private static rayl;
  11374. /**
  11375. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11376. * @param sega the first point of the segment to test the intersection against
  11377. * @param segb the second point of the segment to test the intersection against
  11378. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11379. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11380. */
  11381. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11382. /**
  11383. * Update the ray from viewport position
  11384. * @param x position
  11385. * @param y y position
  11386. * @param viewportWidth viewport width
  11387. * @param viewportHeight viewport height
  11388. * @param world world matrix
  11389. * @param view view matrix
  11390. * @param projection projection matrix
  11391. * @returns this ray updated
  11392. */
  11393. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11394. /**
  11395. * Creates a ray with origin and direction of 0,0,0
  11396. * @returns the new ray
  11397. */
  11398. static Zero(): Ray;
  11399. /**
  11400. * Creates a new ray from screen space and viewport
  11401. * @param x position
  11402. * @param y y position
  11403. * @param viewportWidth viewport width
  11404. * @param viewportHeight viewport height
  11405. * @param world world matrix
  11406. * @param view view matrix
  11407. * @param projection projection matrix
  11408. * @returns new ray
  11409. */
  11410. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11411. /**
  11412. * 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
  11413. * transformed to the given world matrix.
  11414. * @param origin The origin point
  11415. * @param end The end point
  11416. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11417. * @returns the new ray
  11418. */
  11419. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11420. /**
  11421. * Transforms a ray by a matrix
  11422. * @param ray ray to transform
  11423. * @param matrix matrix to apply
  11424. * @returns the resulting new ray
  11425. */
  11426. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11427. /**
  11428. * Transforms a ray by a matrix
  11429. * @param ray ray to transform
  11430. * @param matrix matrix to apply
  11431. * @param result ray to store result in
  11432. */
  11433. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11434. /**
  11435. * Unproject a ray from screen space to object space
  11436. * @param sourceX defines the screen space x coordinate to use
  11437. * @param sourceY defines the screen space y coordinate to use
  11438. * @param viewportWidth defines the current width of the viewport
  11439. * @param viewportHeight defines the current height of the viewport
  11440. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11441. * @param view defines the view matrix to use
  11442. * @param projection defines the projection matrix to use
  11443. */
  11444. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11445. }
  11446. /**
  11447. * Type used to define predicate used to select faces when a mesh intersection is detected
  11448. */
  11449. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11450. interface Scene {
  11451. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  11452. /** @hidden */ private _cachedRayForTransform: Ray;
  11453. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  11454. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11455. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11456. }
  11457. }
  11458. declare module BABYLON {
  11459. /**
  11460. * Groups all the scene component constants in one place to ease maintenance.
  11461. * @hidden
  11462. */
  11463. export class SceneComponentConstants {
  11464. static readonly NAME_EFFECTLAYER: string;
  11465. static readonly NAME_LAYER: string;
  11466. static readonly NAME_LENSFLARESYSTEM: string;
  11467. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11468. static readonly NAME_PARTICLESYSTEM: string;
  11469. static readonly NAME_GAMEPAD: string;
  11470. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11471. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11472. static readonly NAME_DEPTHRENDERER: string;
  11473. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11474. static readonly NAME_SPRITE: string;
  11475. static readonly NAME_OUTLINERENDERER: string;
  11476. static readonly NAME_PROCEDURALTEXTURE: string;
  11477. static readonly NAME_SHADOWGENERATOR: string;
  11478. static readonly NAME_OCTREE: string;
  11479. static readonly NAME_PHYSICSENGINE: string;
  11480. static readonly NAME_AUDIO: string;
  11481. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11482. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11483. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11484. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11485. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11486. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11487. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11488. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11489. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11490. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11491. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11492. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11493. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11494. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11495. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11496. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11497. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11498. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11499. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11500. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11501. static readonly STEP_AFTERRENDER_AUDIO: number;
  11502. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11503. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11504. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11505. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11506. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11507. static readonly STEP_POINTERMOVE_SPRITE: number;
  11508. static readonly STEP_POINTERDOWN_SPRITE: number;
  11509. static readonly STEP_POINTERUP_SPRITE: number;
  11510. }
  11511. /**
  11512. * This represents a scene component.
  11513. *
  11514. * This is used to decouple the dependency the scene is having on the different workloads like
  11515. * layers, post processes...
  11516. */
  11517. export interface ISceneComponent {
  11518. /**
  11519. * The name of the component. Each component must have a unique name.
  11520. */
  11521. name: string;
  11522. /**
  11523. * The scene the component belongs to.
  11524. */
  11525. scene: Scene;
  11526. /**
  11527. * Register the component to one instance of a scene.
  11528. */
  11529. register(): void;
  11530. /**
  11531. * Rebuilds the elements related to this component in case of
  11532. * context lost for instance.
  11533. */
  11534. rebuild(): void;
  11535. /**
  11536. * Disposes the component and the associated ressources.
  11537. */
  11538. dispose(): void;
  11539. }
  11540. /**
  11541. * This represents a SERIALIZABLE scene component.
  11542. *
  11543. * This extends Scene Component to add Serialization methods on top.
  11544. */
  11545. export interface ISceneSerializableComponent extends ISceneComponent {
  11546. /**
  11547. * Adds all the element from the container to the scene
  11548. * @param container the container holding the elements
  11549. */
  11550. addFromContainer(container: AbstractScene): void;
  11551. /**
  11552. * Removes all the elements in the container from the scene
  11553. * @param container contains the elements to remove
  11554. * @param dispose if the removed element should be disposed (default: false)
  11555. */
  11556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11557. /**
  11558. * Serializes the component data to the specified json object
  11559. * @param serializationObject The object to serialize to
  11560. */
  11561. serialize(serializationObject: any): void;
  11562. }
  11563. /**
  11564. * Strong typing of a Mesh related stage step action
  11565. */
  11566. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11567. /**
  11568. * Strong typing of a Evaluate Sub Mesh related stage step action
  11569. */
  11570. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11571. /**
  11572. * Strong typing of a Active Mesh related stage step action
  11573. */
  11574. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11575. /**
  11576. * Strong typing of a Camera related stage step action
  11577. */
  11578. export type CameraStageAction = (camera: Camera) => void;
  11579. /**
  11580. * Strong typing of a Camera Frame buffer related stage step action
  11581. */
  11582. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11583. /**
  11584. * Strong typing of a Render Target related stage step action
  11585. */
  11586. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11587. /**
  11588. * Strong typing of a RenderingGroup related stage step action
  11589. */
  11590. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11591. /**
  11592. * Strong typing of a Mesh Render related stage step action
  11593. */
  11594. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11595. /**
  11596. * Strong typing of a simple stage step action
  11597. */
  11598. export type SimpleStageAction = () => void;
  11599. /**
  11600. * Strong typing of a render target action.
  11601. */
  11602. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11603. /**
  11604. * Strong typing of a pointer move action.
  11605. */
  11606. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11607. /**
  11608. * Strong typing of a pointer up/down action.
  11609. */
  11610. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11611. /**
  11612. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11613. * @hidden
  11614. */
  11615. export class Stage<T extends Function> extends Array<{
  11616. index: number;
  11617. component: ISceneComponent;
  11618. action: T;
  11619. }> {
  11620. /**
  11621. * Hide ctor from the rest of the world.
  11622. * @param items The items to add.
  11623. */
  11624. private constructor();
  11625. /**
  11626. * Creates a new Stage.
  11627. * @returns A new instance of a Stage
  11628. */
  11629. static Create<T extends Function>(): Stage<T>;
  11630. /**
  11631. * Registers a step in an ordered way in the targeted stage.
  11632. * @param index Defines the position to register the step in
  11633. * @param component Defines the component attached to the step
  11634. * @param action Defines the action to launch during the step
  11635. */
  11636. registerStep(index: number, component: ISceneComponent, action: T): void;
  11637. /**
  11638. * Clears all the steps from the stage.
  11639. */
  11640. clear(): void;
  11641. }
  11642. }
  11643. declare module BABYLON {
  11644. interface Scene {
  11645. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11646. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11647. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11648. /**
  11649. * All of the sprite managers added to this scene
  11650. * @see http://doc.babylonjs.com/babylon101/sprites
  11651. */
  11652. spriteManagers: Array<ISpriteManager>;
  11653. /**
  11654. * An event triggered when sprites rendering is about to start
  11655. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11656. */
  11657. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11658. /**
  11659. * An event triggered when sprites rendering is done
  11660. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11661. */
  11662. onAfterSpritesRenderingObservable: Observable<Scene>;
  11663. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11664. /** Launch a ray to try to pick a sprite in the scene
  11665. * @param x position on screen
  11666. * @param y position on screen
  11667. * @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
  11668. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11669. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11670. * @returns a PickingInfo
  11671. */
  11672. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11673. /** Use the given ray to pick a sprite in the scene
  11674. * @param ray The ray (in world space) to use to pick meshes
  11675. * @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
  11676. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11677. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11678. * @returns a PickingInfo
  11679. */
  11680. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11681. /**
  11682. * Force the sprite under the pointer
  11683. * @param sprite defines the sprite to use
  11684. */
  11685. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11686. /**
  11687. * Gets the sprite under the pointer
  11688. * @returns a Sprite or null if no sprite is under the pointer
  11689. */
  11690. getPointerOverSprite(): Nullable<Sprite>;
  11691. }
  11692. /**
  11693. * Defines the sprite scene component responsible to manage sprites
  11694. * in a given scene.
  11695. */
  11696. export class SpriteSceneComponent implements ISceneComponent {
  11697. /**
  11698. * The component name helpfull to identify the component in the list of scene components.
  11699. */
  11700. readonly name: string;
  11701. /**
  11702. * The scene the component belongs to.
  11703. */
  11704. scene: Scene;
  11705. /** @hidden */
  11706. private _spritePredicate;
  11707. /**
  11708. * Creates a new instance of the component for the given scene
  11709. * @param scene Defines the scene to register the component in
  11710. */
  11711. constructor(scene: Scene);
  11712. /**
  11713. * Registers the component in a given scene
  11714. */
  11715. register(): void;
  11716. /**
  11717. * Rebuilds the elements related to this component in case of
  11718. * context lost for instance.
  11719. */
  11720. rebuild(): void;
  11721. /**
  11722. * Disposes the component and the associated ressources.
  11723. */
  11724. dispose(): void;
  11725. private _pickSpriteButKeepRay;
  11726. private _pointerMove;
  11727. private _pointerDown;
  11728. private _pointerUp;
  11729. }
  11730. }
  11731. declare module BABYLON {
  11732. /** @hidden */
  11733. export var fogFragmentDeclaration: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module BABYLON {
  11739. /** @hidden */
  11740. export var fogFragment: {
  11741. name: string;
  11742. shader: string;
  11743. };
  11744. }
  11745. declare module BABYLON {
  11746. /** @hidden */
  11747. export var spritesPixelShader: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module BABYLON {
  11753. /** @hidden */
  11754. export var fogVertexDeclaration: {
  11755. name: string;
  11756. shader: string;
  11757. };
  11758. }
  11759. declare module BABYLON {
  11760. /** @hidden */
  11761. export var spritesVertexShader: {
  11762. name: string;
  11763. shader: string;
  11764. };
  11765. }
  11766. declare module BABYLON {
  11767. /**
  11768. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11769. */
  11770. export interface ISpriteManager extends IDisposable {
  11771. /**
  11772. * Restricts the camera to viewing objects with the same layerMask.
  11773. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11774. */
  11775. layerMask: number;
  11776. /**
  11777. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11778. */
  11779. isPickable: boolean;
  11780. /**
  11781. * Specifies the rendering group id for this mesh (0 by default)
  11782. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11783. */
  11784. renderingGroupId: number;
  11785. /**
  11786. * Defines the list of sprites managed by the manager.
  11787. */
  11788. sprites: Array<Sprite>;
  11789. /**
  11790. * Tests the intersection of a sprite with a specific ray.
  11791. * @param ray The ray we are sending to test the collision
  11792. * @param camera The camera space we are sending rays in
  11793. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11794. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11795. * @returns picking info or null.
  11796. */
  11797. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11798. /**
  11799. * Renders the list of sprites on screen.
  11800. */
  11801. render(): void;
  11802. }
  11803. /**
  11804. * Class used to manage multiple sprites on the same spritesheet
  11805. * @see http://doc.babylonjs.com/babylon101/sprites
  11806. */
  11807. export class SpriteManager implements ISpriteManager {
  11808. /** defines the manager's name */
  11809. name: string;
  11810. /** Gets the list of sprites */
  11811. sprites: Sprite[];
  11812. /** Gets or sets the rendering group id (0 by default) */
  11813. renderingGroupId: number;
  11814. /** Gets or sets camera layer mask */
  11815. layerMask: number;
  11816. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11817. fogEnabled: boolean;
  11818. /** Gets or sets a boolean indicating if the sprites are pickable */
  11819. isPickable: boolean;
  11820. /** Defines the default width of a cell in the spritesheet */
  11821. cellWidth: number;
  11822. /** Defines the default height of a cell in the spritesheet */
  11823. cellHeight: number;
  11824. /**
  11825. * An event triggered when the manager is disposed.
  11826. */
  11827. onDisposeObservable: Observable<SpriteManager>;
  11828. private _onDisposeObserver;
  11829. /**
  11830. * Callback called when the manager is disposed
  11831. */
  11832. onDispose: () => void;
  11833. private _capacity;
  11834. private _spriteTexture;
  11835. private _epsilon;
  11836. private _scene;
  11837. private _vertexData;
  11838. private _buffer;
  11839. private _vertexBuffers;
  11840. private _indexBuffer;
  11841. private _effectBase;
  11842. private _effectFog;
  11843. /**
  11844. * Gets or sets the spritesheet texture
  11845. */
  11846. texture: Texture;
  11847. /**
  11848. * Creates a new sprite manager
  11849. * @param name defines the manager's name
  11850. * @param imgUrl defines the sprite sheet url
  11851. * @param capacity defines the maximum allowed number of sprites
  11852. * @param cellSize defines the size of a sprite cell
  11853. * @param scene defines the hosting scene
  11854. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11855. * @param samplingMode defines the smapling mode to use with spritesheet
  11856. */
  11857. constructor(
  11858. /** defines the manager's name */
  11859. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11860. private _appendSpriteVertex;
  11861. /**
  11862. * Intersects the sprites with a ray
  11863. * @param ray defines the ray to intersect with
  11864. * @param camera defines the current active camera
  11865. * @param predicate defines a predicate used to select candidate sprites
  11866. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11867. * @returns null if no hit or a PickingInfo
  11868. */
  11869. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11870. /**
  11871. * Render all child sprites
  11872. */
  11873. render(): void;
  11874. /**
  11875. * Release associated resources
  11876. */
  11877. dispose(): void;
  11878. }
  11879. }
  11880. declare module BABYLON {
  11881. /**
  11882. * Class used to represent a sprite
  11883. * @see http://doc.babylonjs.com/babylon101/sprites
  11884. */
  11885. export class Sprite {
  11886. /** defines the name */
  11887. name: string;
  11888. /** Gets or sets the current world position */
  11889. position: Vector3;
  11890. /** Gets or sets the main color */
  11891. color: Color4;
  11892. /** Gets or sets the width */
  11893. width: number;
  11894. /** Gets or sets the height */
  11895. height: number;
  11896. /** Gets or sets rotation angle */
  11897. angle: number;
  11898. /** Gets or sets the cell index in the sprite sheet */
  11899. cellIndex: number;
  11900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11901. invertU: number;
  11902. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11903. invertV: number;
  11904. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11905. disposeWhenFinishedAnimating: boolean;
  11906. /** Gets the list of attached animations */
  11907. animations: Animation[];
  11908. /** Gets or sets a boolean indicating if the sprite can be picked */
  11909. isPickable: boolean;
  11910. /**
  11911. * Gets or sets the associated action manager
  11912. */
  11913. actionManager: Nullable<ActionManager>;
  11914. private _animationStarted;
  11915. private _loopAnimation;
  11916. private _fromIndex;
  11917. private _toIndex;
  11918. private _delay;
  11919. private _direction;
  11920. private _manager;
  11921. private _time;
  11922. private _onAnimationEnd;
  11923. /**
  11924. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11925. */
  11926. isVisible: boolean;
  11927. /**
  11928. * Gets or sets the sprite size
  11929. */
  11930. size: number;
  11931. /**
  11932. * Creates a new Sprite
  11933. * @param name defines the name
  11934. * @param manager defines the manager
  11935. */
  11936. constructor(
  11937. /** defines the name */
  11938. name: string, manager: ISpriteManager);
  11939. /**
  11940. * Starts an animation
  11941. * @param from defines the initial key
  11942. * @param to defines the end key
  11943. * @param loop defines if the animation must loop
  11944. * @param delay defines the start delay (in ms)
  11945. * @param onAnimationEnd defines a callback to call when animation ends
  11946. */
  11947. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11948. /** Stops current animation (if any) */
  11949. stopAnimation(): void;
  11950. /** @hidden */ private _animate(deltaTime: number): void;
  11951. /** Release associated resources */
  11952. dispose(): void;
  11953. }
  11954. }
  11955. declare module BABYLON {
  11956. /**
  11957. * Information about the result of picking within a scene
  11958. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11959. */
  11960. export class PickingInfo {
  11961. /** @hidden */ private _pickingUnavailable: boolean;
  11962. /**
  11963. * If the pick collided with an object
  11964. */
  11965. hit: boolean;
  11966. /**
  11967. * Distance away where the pick collided
  11968. */
  11969. distance: number;
  11970. /**
  11971. * The location of pick collision
  11972. */
  11973. pickedPoint: Nullable<Vector3>;
  11974. /**
  11975. * The mesh corresponding the the pick collision
  11976. */
  11977. pickedMesh: Nullable<AbstractMesh>;
  11978. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11979. bu: number;
  11980. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11981. bv: number;
  11982. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11983. faceId: number;
  11984. /** Id of the the submesh that was picked */
  11985. subMeshId: number;
  11986. /** If a sprite was picked, this will be the sprite the pick collided with */
  11987. pickedSprite: Nullable<Sprite>;
  11988. /**
  11989. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11990. */
  11991. originMesh: Nullable<AbstractMesh>;
  11992. /**
  11993. * The ray that was used to perform the picking.
  11994. */
  11995. ray: Nullable<Ray>;
  11996. /**
  11997. * Gets the normal correspodning to the face the pick collided with
  11998. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11999. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12000. * @returns The normal correspodning to the face the pick collided with
  12001. */
  12002. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12003. /**
  12004. * Gets the texture coordinates of where the pick occured
  12005. * @returns the vector containing the coordnates of the texture
  12006. */
  12007. getTextureCoordinates(): Nullable<Vector2>;
  12008. }
  12009. }
  12010. declare module BABYLON {
  12011. /**
  12012. * Gather the list of pointer event types as constants.
  12013. */
  12014. export class PointerEventTypes {
  12015. /**
  12016. * 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.
  12017. */
  12018. static readonly POINTERDOWN: number;
  12019. /**
  12020. * The pointerup event is fired when a pointer is no longer active.
  12021. */
  12022. static readonly POINTERUP: number;
  12023. /**
  12024. * The pointermove event is fired when a pointer changes coordinates.
  12025. */
  12026. static readonly POINTERMOVE: number;
  12027. /**
  12028. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12029. */
  12030. static readonly POINTERWHEEL: number;
  12031. /**
  12032. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12033. */
  12034. static readonly POINTERPICK: number;
  12035. /**
  12036. * The pointertap event is fired when a the object has been touched and released without drag.
  12037. */
  12038. static readonly POINTERTAP: number;
  12039. /**
  12040. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12041. */
  12042. static readonly POINTERDOUBLETAP: number;
  12043. }
  12044. /**
  12045. * Base class of pointer info types.
  12046. */
  12047. export class PointerInfoBase {
  12048. /**
  12049. * Defines the type of event (PointerEventTypes)
  12050. */
  12051. type: number;
  12052. /**
  12053. * Defines the related dom event
  12054. */
  12055. event: PointerEvent | MouseWheelEvent;
  12056. /**
  12057. * Instantiates the base class of pointers info.
  12058. * @param type Defines the type of event (PointerEventTypes)
  12059. * @param event Defines the related dom event
  12060. */
  12061. constructor(
  12062. /**
  12063. * Defines the type of event (PointerEventTypes)
  12064. */
  12065. type: number,
  12066. /**
  12067. * Defines the related dom event
  12068. */
  12069. event: PointerEvent | MouseWheelEvent);
  12070. }
  12071. /**
  12072. * This class is used to store pointer related info for the onPrePointerObservable event.
  12073. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12074. */
  12075. export class PointerInfoPre extends PointerInfoBase {
  12076. /**
  12077. * Ray from a pointer if availible (eg. 6dof controller)
  12078. */
  12079. ray: Nullable<Ray>;
  12080. /**
  12081. * Defines the local position of the pointer on the canvas.
  12082. */
  12083. localPosition: Vector2;
  12084. /**
  12085. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12086. */
  12087. skipOnPointerObservable: boolean;
  12088. /**
  12089. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12090. * @param type Defines the type of event (PointerEventTypes)
  12091. * @param event Defines the related dom event
  12092. * @param localX Defines the local x coordinates of the pointer when the event occured
  12093. * @param localY Defines the local y coordinates of the pointer when the event occured
  12094. */
  12095. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12096. }
  12097. /**
  12098. * This type contains all the data related to a pointer event in Babylon.js.
  12099. * 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.
  12100. */
  12101. export class PointerInfo extends PointerInfoBase {
  12102. /**
  12103. * Defines the picking info associated to the info (if any)\
  12104. */
  12105. pickInfo: Nullable<PickingInfo>;
  12106. /**
  12107. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12108. * @param type Defines the type of event (PointerEventTypes)
  12109. * @param event Defines the related dom event
  12110. * @param pickInfo Defines the picking info associated to the info (if any)\
  12111. */
  12112. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12113. /**
  12114. * Defines the picking info associated to the info (if any)\
  12115. */
  12116. pickInfo: Nullable<PickingInfo>);
  12117. }
  12118. /**
  12119. * Data relating to a touch event on the screen.
  12120. */
  12121. export interface PointerTouch {
  12122. /**
  12123. * X coordinate of touch.
  12124. */
  12125. x: number;
  12126. /**
  12127. * Y coordinate of touch.
  12128. */
  12129. y: number;
  12130. /**
  12131. * Id of touch. Unique for each finger.
  12132. */
  12133. pointerId: number;
  12134. /**
  12135. * Event type passed from DOM.
  12136. */
  12137. type: any;
  12138. }
  12139. }
  12140. declare module BABYLON {
  12141. /**
  12142. * Manage the mouse inputs to control the movement of a free camera.
  12143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12144. */
  12145. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12146. /**
  12147. * Define if touch is enabled in the mouse input
  12148. */
  12149. touchEnabled: boolean;
  12150. /**
  12151. * Defines the camera the input is attached to.
  12152. */
  12153. camera: FreeCamera;
  12154. /**
  12155. * Defines the buttons associated with the input to handle camera move.
  12156. */
  12157. buttons: number[];
  12158. /**
  12159. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12160. */
  12161. angularSensibility: number;
  12162. private _pointerInput;
  12163. private _onMouseMove;
  12164. private _observer;
  12165. private previousPosition;
  12166. /**
  12167. * Observable for when a pointer move event occurs containing the move offset
  12168. */
  12169. onPointerMovedObservable: Observable<{
  12170. offsetX: number;
  12171. offsetY: number;
  12172. }>;
  12173. /**
  12174. * @hidden
  12175. * If the camera should be rotated automatically based on pointer movement
  12176. */ private _allowCameraRotation: boolean;
  12177. /**
  12178. * Manage the mouse inputs to control the movement of a free camera.
  12179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12180. * @param touchEnabled Defines if touch is enabled or not
  12181. */
  12182. constructor(
  12183. /**
  12184. * Define if touch is enabled in the mouse input
  12185. */
  12186. touchEnabled?: boolean);
  12187. /**
  12188. * Attach the input controls to a specific dom element to get the input from.
  12189. * @param element Defines the element the controls should be listened from
  12190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12191. */
  12192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12193. /**
  12194. * Called on JS contextmenu event.
  12195. * Override this method to provide functionality.
  12196. */
  12197. protected onContextMenu(evt: PointerEvent): void;
  12198. /**
  12199. * Detach the current controls from the specified dom element.
  12200. * @param element Defines the element to stop listening the inputs from
  12201. */
  12202. detachControl(element: Nullable<HTMLElement>): void;
  12203. /**
  12204. * Gets the class name of the current intput.
  12205. * @returns the class name
  12206. */
  12207. getClassName(): string;
  12208. /**
  12209. * Get the friendly name associated with the input class.
  12210. * @returns the input friendly name
  12211. */
  12212. getSimpleName(): string;
  12213. }
  12214. }
  12215. declare module BABYLON {
  12216. /**
  12217. * Manage the touch inputs to control the movement of a free camera.
  12218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12219. */
  12220. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12221. /**
  12222. * Defines the camera the input is attached to.
  12223. */
  12224. camera: FreeCamera;
  12225. /**
  12226. * Defines the touch sensibility for rotation.
  12227. * The higher the faster.
  12228. */
  12229. touchAngularSensibility: number;
  12230. /**
  12231. * Defines the touch sensibility for move.
  12232. * The higher the faster.
  12233. */
  12234. touchMoveSensibility: number;
  12235. private _offsetX;
  12236. private _offsetY;
  12237. private _pointerPressed;
  12238. private _pointerInput;
  12239. private _observer;
  12240. private _onLostFocus;
  12241. /**
  12242. * Attach the input controls to a specific dom element to get the input from.
  12243. * @param element Defines the element the controls should be listened from
  12244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12245. */
  12246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12247. /**
  12248. * Detach the current controls from the specified dom element.
  12249. * @param element Defines the element to stop listening the inputs from
  12250. */
  12251. detachControl(element: Nullable<HTMLElement>): void;
  12252. /**
  12253. * Update the current camera state depending on the inputs that have been used this frame.
  12254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12255. */
  12256. checkInputs(): void;
  12257. /**
  12258. * Gets the class name of the current intput.
  12259. * @returns the class name
  12260. */
  12261. getClassName(): string;
  12262. /**
  12263. * Get the friendly name associated with the input class.
  12264. * @returns the input friendly name
  12265. */
  12266. getSimpleName(): string;
  12267. }
  12268. }
  12269. declare module BABYLON {
  12270. /**
  12271. * Default Inputs manager for the FreeCamera.
  12272. * It groups all the default supported inputs for ease of use.
  12273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12274. */
  12275. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12276. /**
  12277. * @hidden
  12278. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  12279. /**
  12280. * Instantiates a new FreeCameraInputsManager.
  12281. * @param camera Defines the camera the inputs belong to
  12282. */
  12283. constructor(camera: FreeCamera);
  12284. /**
  12285. * Add keyboard input support to the input manager.
  12286. * @returns the current input manager
  12287. */
  12288. addKeyboard(): FreeCameraInputsManager;
  12289. /**
  12290. * Add mouse input support to the input manager.
  12291. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12292. * @returns the current input manager
  12293. */
  12294. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12295. /**
  12296. * Removes the mouse input support from the manager
  12297. * @returns the current input manager
  12298. */
  12299. removeMouse(): FreeCameraInputsManager;
  12300. /**
  12301. * Add touch input support to the input manager.
  12302. * @returns the current input manager
  12303. */
  12304. addTouch(): FreeCameraInputsManager;
  12305. /**
  12306. * Remove all attached input methods from a camera
  12307. */
  12308. clear(): void;
  12309. }
  12310. }
  12311. declare module BABYLON {
  12312. /**
  12313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12314. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12316. */
  12317. export class FreeCamera extends TargetCamera {
  12318. /**
  12319. * Define the collision ellipsoid of the camera.
  12320. * This is helpful to simulate a camera body like the player body around the camera
  12321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12322. */
  12323. ellipsoid: Vector3;
  12324. /**
  12325. * Define an offset for the position of the ellipsoid around the camera.
  12326. * This can be helpful to determine the center of the body near the gravity center of the body
  12327. * instead of its head.
  12328. */
  12329. ellipsoidOffset: Vector3;
  12330. /**
  12331. * Enable or disable collisions of the camera with the rest of the scene objects.
  12332. */
  12333. checkCollisions: boolean;
  12334. /**
  12335. * Enable or disable gravity on the camera.
  12336. */
  12337. applyGravity: boolean;
  12338. /**
  12339. * Define the input manager associated to the camera.
  12340. */
  12341. inputs: FreeCameraInputsManager;
  12342. /**
  12343. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12344. * Higher values reduce sensitivity.
  12345. */
  12346. /**
  12347. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12348. * Higher values reduce sensitivity.
  12349. */
  12350. angularSensibility: number;
  12351. /**
  12352. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12353. */
  12354. keysUp: number[];
  12355. /**
  12356. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12357. */
  12358. keysDown: number[];
  12359. /**
  12360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12361. */
  12362. keysLeft: number[];
  12363. /**
  12364. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12365. */
  12366. keysRight: number[];
  12367. /**
  12368. * Event raised when the camera collide with a mesh in the scene.
  12369. */
  12370. onCollide: (collidedMesh: AbstractMesh) => void;
  12371. private _collider;
  12372. private _needMoveForGravity;
  12373. private _oldPosition;
  12374. private _diffPosition;
  12375. private _newPosition;
  12376. /** @hidden */ private _localDirection: Vector3;
  12377. /** @hidden */ private _transformedDirection: Vector3;
  12378. /**
  12379. * Instantiates a Free Camera.
  12380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12381. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12383. * @param name Define the name of the camera in the scene
  12384. * @param position Define the start position of the camera in the scene
  12385. * @param scene Define the scene the camera belongs to
  12386. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12387. */
  12388. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12389. /**
  12390. * Attached controls to the current camera.
  12391. * @param element Defines the element the controls should be listened from
  12392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12393. */
  12394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12395. /**
  12396. * Detach the current controls from the camera.
  12397. * The camera will stop reacting to inputs.
  12398. * @param element Defines the element to stop listening the inputs from
  12399. */
  12400. detachControl(element: HTMLElement): void;
  12401. private _collisionMask;
  12402. /**
  12403. * Define a collision mask to limit the list of object the camera can collide with
  12404. */
  12405. collisionMask: number;
  12406. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  12407. private _onCollisionPositionChange;
  12408. /** @hidden */ private _checkInputs(): void;
  12409. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  12410. /** @hidden */ private _updatePosition(): void;
  12411. /**
  12412. * Destroy the camera and release the current resources hold by it.
  12413. */
  12414. dispose(): void;
  12415. /**
  12416. * Gets the current object class name.
  12417. * @return the class name
  12418. */
  12419. getClassName(): string;
  12420. }
  12421. }
  12422. declare module BABYLON {
  12423. /**
  12424. * Represents a gamepad control stick position
  12425. */
  12426. export class StickValues {
  12427. /**
  12428. * The x component of the control stick
  12429. */
  12430. x: number;
  12431. /**
  12432. * The y component of the control stick
  12433. */
  12434. y: number;
  12435. /**
  12436. * Initializes the gamepad x and y control stick values
  12437. * @param x The x component of the gamepad control stick value
  12438. * @param y The y component of the gamepad control stick value
  12439. */
  12440. constructor(
  12441. /**
  12442. * The x component of the control stick
  12443. */
  12444. x: number,
  12445. /**
  12446. * The y component of the control stick
  12447. */
  12448. y: number);
  12449. }
  12450. /**
  12451. * An interface which manages callbacks for gamepad button changes
  12452. */
  12453. export interface GamepadButtonChanges {
  12454. /**
  12455. * Called when a gamepad has been changed
  12456. */
  12457. changed: boolean;
  12458. /**
  12459. * Called when a gamepad press event has been triggered
  12460. */
  12461. pressChanged: boolean;
  12462. /**
  12463. * Called when a touch event has been triggered
  12464. */
  12465. touchChanged: boolean;
  12466. /**
  12467. * Called when a value has changed
  12468. */
  12469. valueChanged: boolean;
  12470. }
  12471. /**
  12472. * Represents a gamepad
  12473. */
  12474. export class Gamepad {
  12475. /**
  12476. * The id of the gamepad
  12477. */
  12478. id: string;
  12479. /**
  12480. * The index of the gamepad
  12481. */
  12482. index: number;
  12483. /**
  12484. * The browser gamepad
  12485. */
  12486. browserGamepad: any;
  12487. /**
  12488. * Specifies what type of gamepad this represents
  12489. */
  12490. type: number;
  12491. private _leftStick;
  12492. private _rightStick;
  12493. /** @hidden */ private _isConnected: boolean;
  12494. private _leftStickAxisX;
  12495. private _leftStickAxisY;
  12496. private _rightStickAxisX;
  12497. private _rightStickAxisY;
  12498. /**
  12499. * Triggered when the left control stick has been changed
  12500. */
  12501. private _onleftstickchanged;
  12502. /**
  12503. * Triggered when the right control stick has been changed
  12504. */
  12505. private _onrightstickchanged;
  12506. /**
  12507. * Represents a gamepad controller
  12508. */
  12509. static GAMEPAD: number;
  12510. /**
  12511. * Represents a generic controller
  12512. */
  12513. static GENERIC: number;
  12514. /**
  12515. * Represents an XBox controller
  12516. */
  12517. static XBOX: number;
  12518. /**
  12519. * Represents a pose-enabled controller
  12520. */
  12521. static POSE_ENABLED: number;
  12522. /**
  12523. * Specifies whether the left control stick should be Y-inverted
  12524. */
  12525. protected _invertLeftStickY: boolean;
  12526. /**
  12527. * Specifies if the gamepad has been connected
  12528. */
  12529. readonly isConnected: boolean;
  12530. /**
  12531. * Initializes the gamepad
  12532. * @param id The id of the gamepad
  12533. * @param index The index of the gamepad
  12534. * @param browserGamepad The browser gamepad
  12535. * @param leftStickX The x component of the left joystick
  12536. * @param leftStickY The y component of the left joystick
  12537. * @param rightStickX The x component of the right joystick
  12538. * @param rightStickY The y component of the right joystick
  12539. */
  12540. constructor(
  12541. /**
  12542. * The id of the gamepad
  12543. */
  12544. id: string,
  12545. /**
  12546. * The index of the gamepad
  12547. */
  12548. index: number,
  12549. /**
  12550. * The browser gamepad
  12551. */
  12552. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12553. /**
  12554. * Callback triggered when the left joystick has changed
  12555. * @param callback
  12556. */
  12557. onleftstickchanged(callback: (values: StickValues) => void): void;
  12558. /**
  12559. * Callback triggered when the right joystick has changed
  12560. * @param callback
  12561. */
  12562. onrightstickchanged(callback: (values: StickValues) => void): void;
  12563. /**
  12564. * Gets the left joystick
  12565. */
  12566. /**
  12567. * Sets the left joystick values
  12568. */
  12569. leftStick: StickValues;
  12570. /**
  12571. * Gets the right joystick
  12572. */
  12573. /**
  12574. * Sets the right joystick value
  12575. */
  12576. rightStick: StickValues;
  12577. /**
  12578. * Updates the gamepad joystick positions
  12579. */
  12580. update(): void;
  12581. /**
  12582. * Disposes the gamepad
  12583. */
  12584. dispose(): void;
  12585. }
  12586. /**
  12587. * Represents a generic gamepad
  12588. */
  12589. export class GenericPad extends Gamepad {
  12590. private _buttons;
  12591. private _onbuttondown;
  12592. private _onbuttonup;
  12593. /**
  12594. * Observable triggered when a button has been pressed
  12595. */
  12596. onButtonDownObservable: Observable<number>;
  12597. /**
  12598. * Observable triggered when a button has been released
  12599. */
  12600. onButtonUpObservable: Observable<number>;
  12601. /**
  12602. * Callback triggered when a button has been pressed
  12603. * @param callback Called when a button has been pressed
  12604. */
  12605. onbuttondown(callback: (buttonPressed: number) => void): void;
  12606. /**
  12607. * Callback triggered when a button has been released
  12608. * @param callback Called when a button has been released
  12609. */
  12610. onbuttonup(callback: (buttonReleased: number) => void): void;
  12611. /**
  12612. * Initializes the generic gamepad
  12613. * @param id The id of the generic gamepad
  12614. * @param index The index of the generic gamepad
  12615. * @param browserGamepad The browser gamepad
  12616. */
  12617. constructor(id: string, index: number, browserGamepad: any);
  12618. private _setButtonValue;
  12619. /**
  12620. * Updates the generic gamepad
  12621. */
  12622. update(): void;
  12623. /**
  12624. * Disposes the generic gamepad
  12625. */
  12626. dispose(): void;
  12627. }
  12628. }
  12629. declare module BABYLON {
  12630. /**
  12631. * Defines the types of pose enabled controllers that are supported
  12632. */
  12633. export enum PoseEnabledControllerType {
  12634. /**
  12635. * HTC Vive
  12636. */
  12637. VIVE = 0,
  12638. /**
  12639. * Oculus Rift
  12640. */
  12641. OCULUS = 1,
  12642. /**
  12643. * Windows mixed reality
  12644. */
  12645. WINDOWS = 2,
  12646. /**
  12647. * Samsung gear VR
  12648. */
  12649. GEAR_VR = 3,
  12650. /**
  12651. * Google Daydream
  12652. */
  12653. DAYDREAM = 4,
  12654. /**
  12655. * Generic
  12656. */
  12657. GENERIC = 5
  12658. }
  12659. /**
  12660. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12661. */
  12662. export interface MutableGamepadButton {
  12663. /**
  12664. * Value of the button/trigger
  12665. */
  12666. value: number;
  12667. /**
  12668. * If the button/trigger is currently touched
  12669. */
  12670. touched: boolean;
  12671. /**
  12672. * If the button/trigger is currently pressed
  12673. */
  12674. pressed: boolean;
  12675. }
  12676. /**
  12677. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12678. * @hidden
  12679. */
  12680. export interface ExtendedGamepadButton extends GamepadButton {
  12681. /**
  12682. * If the button/trigger is currently pressed
  12683. */
  12684. readonly pressed: boolean;
  12685. /**
  12686. * If the button/trigger is currently touched
  12687. */
  12688. readonly touched: boolean;
  12689. /**
  12690. * Value of the button/trigger
  12691. */
  12692. readonly value: number;
  12693. }
  12694. /** @hidden */
  12695. export interface _GamePadFactory {
  12696. /**
  12697. * Returns wether or not the current gamepad can be created for this type of controller.
  12698. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12699. * @returns true if it can be created, otherwise false
  12700. */
  12701. canCreate(gamepadInfo: any): boolean;
  12702. /**
  12703. * Creates a new instance of the Gamepad.
  12704. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12705. * @returns the new gamepad instance
  12706. */
  12707. create(gamepadInfo: any): Gamepad;
  12708. }
  12709. /**
  12710. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12711. */
  12712. export class PoseEnabledControllerHelper {
  12713. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12714. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12715. /**
  12716. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12717. * @param vrGamepad the gamepad to initialized
  12718. * @returns a vr controller of the type the gamepad identified as
  12719. */
  12720. static InitiateController(vrGamepad: any): Gamepad;
  12721. }
  12722. /**
  12723. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12724. */
  12725. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12726. private _deviceRoomPosition;
  12727. private _deviceRoomRotationQuaternion;
  12728. /**
  12729. * The device position in babylon space
  12730. */
  12731. devicePosition: Vector3;
  12732. /**
  12733. * The device rotation in babylon space
  12734. */
  12735. deviceRotationQuaternion: Quaternion;
  12736. /**
  12737. * The scale factor of the device in babylon space
  12738. */
  12739. deviceScaleFactor: number;
  12740. /**
  12741. * (Likely devicePosition should be used instead) The device position in its room space
  12742. */
  12743. position: Vector3;
  12744. /**
  12745. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12746. */
  12747. rotationQuaternion: Quaternion;
  12748. /**
  12749. * The type of controller (Eg. Windows mixed reality)
  12750. */
  12751. controllerType: PoseEnabledControllerType;
  12752. protected _calculatedPosition: Vector3;
  12753. private _calculatedRotation;
  12754. /**
  12755. * The raw pose from the device
  12756. */
  12757. rawPose: DevicePose;
  12758. private _trackPosition;
  12759. private _maxRotationDistFromHeadset;
  12760. private _draggedRoomRotation;
  12761. /**
  12762. * @hidden
  12763. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  12764. /**
  12765. * Internal, the mesh attached to the controller
  12766. * @hidden
  12767. */ private _mesh: Nullable<AbstractMesh>;
  12768. private _poseControlledCamera;
  12769. private _leftHandSystemQuaternion;
  12770. /**
  12771. * Internal, matrix used to convert room space to babylon space
  12772. * @hidden
  12773. */ private _deviceToWorld: Matrix;
  12774. /**
  12775. * Node to be used when casting a ray from the controller
  12776. * @hidden
  12777. */ private _pointingPoseNode: Nullable<TransformNode>;
  12778. /**
  12779. * Name of the child mesh that can be used to cast a ray from the controller
  12780. */
  12781. static readonly POINTING_POSE: string;
  12782. /**
  12783. * Creates a new PoseEnabledController from a gamepad
  12784. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12785. */
  12786. constructor(browserGamepad: any);
  12787. private _workingMatrix;
  12788. /**
  12789. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12790. */
  12791. update(): void;
  12792. /**
  12793. * Updates only the pose device and mesh without doing any button event checking
  12794. */
  12795. protected _updatePoseAndMesh(): void;
  12796. /**
  12797. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12798. * @param poseData raw pose fromthe device
  12799. */
  12800. updateFromDevice(poseData: DevicePose): void;
  12801. /**
  12802. * @hidden
  12803. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  12804. /**
  12805. * Attaches a mesh to the controller
  12806. * @param mesh the mesh to be attached
  12807. */
  12808. attachToMesh(mesh: AbstractMesh): void;
  12809. /**
  12810. * Attaches the controllers mesh to a camera
  12811. * @param camera the camera the mesh should be attached to
  12812. */
  12813. attachToPoseControlledCamera(camera: TargetCamera): void;
  12814. /**
  12815. * Disposes of the controller
  12816. */
  12817. dispose(): void;
  12818. /**
  12819. * The mesh that is attached to the controller
  12820. */
  12821. readonly mesh: Nullable<AbstractMesh>;
  12822. /**
  12823. * Gets the ray of the controller in the direction the controller is pointing
  12824. * @param length the length the resulting ray should be
  12825. * @returns a ray in the direction the controller is pointing
  12826. */
  12827. getForwardRay(length?: number): Ray;
  12828. }
  12829. }
  12830. declare module BABYLON {
  12831. /**
  12832. * Defines the WebVRController object that represents controllers tracked in 3D space
  12833. */
  12834. export abstract class WebVRController extends PoseEnabledController {
  12835. /**
  12836. * Internal, the default controller model for the controller
  12837. */
  12838. protected _defaultModel: AbstractMesh;
  12839. /**
  12840. * Fired when the trigger state has changed
  12841. */
  12842. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12843. /**
  12844. * Fired when the main button state has changed
  12845. */
  12846. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12847. /**
  12848. * Fired when the secondary button state has changed
  12849. */
  12850. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12851. /**
  12852. * Fired when the pad state has changed
  12853. */
  12854. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12855. /**
  12856. * Fired when controllers stick values have changed
  12857. */
  12858. onPadValuesChangedObservable: Observable<StickValues>;
  12859. /**
  12860. * Array of button availible on the controller
  12861. */
  12862. protected _buttons: Array<MutableGamepadButton>;
  12863. private _onButtonStateChange;
  12864. /**
  12865. * Fired when a controller button's state has changed
  12866. * @param callback the callback containing the button that was modified
  12867. */
  12868. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12869. /**
  12870. * X and Y axis corrisponding to the controllers joystick
  12871. */
  12872. pad: StickValues;
  12873. /**
  12874. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12875. */
  12876. hand: string;
  12877. /**
  12878. * The default controller model for the controller
  12879. */
  12880. readonly defaultModel: AbstractMesh;
  12881. /**
  12882. * Creates a new WebVRController from a gamepad
  12883. * @param vrGamepad the gamepad that the WebVRController should be created from
  12884. */
  12885. constructor(vrGamepad: any);
  12886. /**
  12887. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12888. */
  12889. update(): void;
  12890. /**
  12891. * Function to be called when a button is modified
  12892. */
  12893. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12894. /**
  12895. * Loads a mesh and attaches it to the controller
  12896. * @param scene the scene the mesh should be added to
  12897. * @param meshLoaded callback for when the mesh has been loaded
  12898. */
  12899. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12900. private _setButtonValue;
  12901. private _changes;
  12902. private _checkChanges;
  12903. /**
  12904. * Disposes of th webVRCOntroller
  12905. */
  12906. dispose(): void;
  12907. }
  12908. }
  12909. declare module BABYLON {
  12910. /**
  12911. * The HemisphericLight simulates the ambient environment light,
  12912. * so the passed direction is the light reflection direction, not the incoming direction.
  12913. */
  12914. export class HemisphericLight extends Light {
  12915. /**
  12916. * The groundColor is the light in the opposite direction to the one specified during creation.
  12917. * 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.
  12918. */
  12919. groundColor: Color3;
  12920. /**
  12921. * The light reflection direction, not the incoming direction.
  12922. */
  12923. direction: Vector3;
  12924. /**
  12925. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12926. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12927. * The HemisphericLight can't cast shadows.
  12928. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12929. * @param name The friendly name of the light
  12930. * @param direction The direction of the light reflection
  12931. * @param scene The scene the light belongs to
  12932. */
  12933. constructor(name: string, direction: Vector3, scene: Scene);
  12934. protected _buildUniformLayout(): void;
  12935. /**
  12936. * Returns the string "HemisphericLight".
  12937. * @return The class name
  12938. */
  12939. getClassName(): string;
  12940. /**
  12941. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12942. * Returns the updated direction.
  12943. * @param target The target the direction should point to
  12944. * @return The computed direction
  12945. */
  12946. setDirectionToTarget(target: Vector3): Vector3;
  12947. /**
  12948. * Returns the shadow generator associated to the light.
  12949. * @returns Always null for hemispheric lights because it does not support shadows.
  12950. */
  12951. getShadowGenerator(): Nullable<IShadowGenerator>;
  12952. /**
  12953. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12954. * @param effect The effect to update
  12955. * @param lightIndex The index of the light in the effect to update
  12956. * @returns The hemispheric light
  12957. */
  12958. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12959. /**
  12960. * Computes the world matrix of the node
  12961. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12962. * @param useWasUpdatedFlag defines a reserved property
  12963. * @returns the world matrix
  12964. */
  12965. computeWorldMatrix(): Matrix;
  12966. /**
  12967. * Returns the integer 3.
  12968. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12969. */
  12970. getTypeID(): number;
  12971. /**
  12972. * Prepares the list of defines specific to the light type.
  12973. * @param defines the list of defines
  12974. * @param lightIndex defines the index of the light for the effect
  12975. */
  12976. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12977. }
  12978. }
  12979. declare module BABYLON {
  12980. /** @hidden */
  12981. export var vrMultiviewToSingleviewPixelShader: {
  12982. name: string;
  12983. shader: string;
  12984. };
  12985. }
  12986. declare module BABYLON {
  12987. /**
  12988. * Renders to multiple views with a single draw call
  12989. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12990. */
  12991. export class MultiviewRenderTarget extends RenderTargetTexture {
  12992. /**
  12993. * Creates a multiview render target
  12994. * @param scene scene used with the render target
  12995. * @param size the size of the render target (used for each view)
  12996. */
  12997. constructor(scene: Scene, size?: number | {
  12998. width: number;
  12999. height: number;
  13000. } | {
  13001. ratio: number;
  13002. });
  13003. /**
  13004. * @hidden
  13005. * @param faceIndex the face index, if its a cube texture
  13006. */ private _bindFrameBuffer(faceIndex?: number): void;
  13007. /**
  13008. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13009. * @returns the view count
  13010. */
  13011. getViewCount(): number;
  13012. }
  13013. }
  13014. declare module BABYLON {
  13015. interface Engine {
  13016. /**
  13017. * Creates a new multiview render target
  13018. * @param width defines the width of the texture
  13019. * @param height defines the height of the texture
  13020. * @returns the created multiview texture
  13021. */
  13022. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13023. /**
  13024. * Binds a multiview framebuffer to be drawn to
  13025. * @param multiviewTexture texture to bind
  13026. */
  13027. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13028. }
  13029. interface Camera {
  13030. /**
  13031. * @hidden
  13032. * 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)
  13033. */ private _useMultiviewToSingleView: boolean;
  13034. /**
  13035. * @hidden
  13036. * 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)
  13037. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  13038. /**
  13039. * @hidden
  13040. * ensures the multiview texture of the camera exists and has the specified width/height
  13041. * @param width height to set on the multiview texture
  13042. * @param height width to set on the multiview texture
  13043. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13044. }
  13045. interface Scene {
  13046. /** @hidden */ private _transformMatrixR: Matrix;
  13047. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  13048. /** @hidden */ private _createMultiviewUbo(): void;
  13049. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13050. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13056. * This will not be used for webXR as it supports displaying texture arrays directly
  13057. */
  13058. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13059. /**
  13060. * Initializes a VRMultiviewToSingleview
  13061. * @param name name of the post process
  13062. * @param camera camera to be applied to
  13063. * @param scaleFactor scaling factor to the size of the output texture
  13064. */
  13065. constructor(name: string, camera: Camera, scaleFactor: number);
  13066. }
  13067. }
  13068. declare module BABYLON {
  13069. /**
  13070. * Defines the interface used by display changed events
  13071. */
  13072. interface IDisplayChangedEventArgs {
  13073. /** Gets the vrDisplay object (if any) */
  13074. vrDisplay: Nullable<any>;
  13075. /** Gets a boolean indicating if webVR is supported */
  13076. vrSupported: boolean;
  13077. }
  13078. interface Engine {
  13079. /** @hidden */ private _vrDisplay: any;
  13080. /** @hidden */ private _vrSupported: boolean;
  13081. /** @hidden */ private _oldSize: Size;
  13082. /** @hidden */ private _oldHardwareScaleFactor: number;
  13083. /** @hidden */ private _vrExclusivePointerMode: boolean;
  13084. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13085. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  13086. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  13087. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  13088. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  13089. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  13090. /**
  13091. * Observable signaled when VR display mode changes
  13092. */
  13093. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13094. /**
  13095. * Observable signaled when VR request present is complete
  13096. */
  13097. onVRRequestPresentComplete: Observable<boolean>;
  13098. /**
  13099. * Observable signaled when VR request present starts
  13100. */
  13101. onVRRequestPresentStart: Observable<Engine>;
  13102. /**
  13103. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13104. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13105. */
  13106. isInVRExclusivePointerMode: boolean;
  13107. /**
  13108. * Gets a boolean indicating if a webVR device was detected
  13109. * @returns true if a webVR device was detected
  13110. */
  13111. isVRDevicePresent(): boolean;
  13112. /**
  13113. * Gets the current webVR device
  13114. * @returns the current webVR device (or null)
  13115. */
  13116. getVRDevice(): any;
  13117. /**
  13118. * Initializes a webVR display and starts listening to display change events
  13119. * The onVRDisplayChangedObservable will be notified upon these changes
  13120. * @returns A promise containing a VRDisplay and if vr is supported
  13121. */
  13122. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13123. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13124. /**
  13125. * Call this function to switch to webVR mode
  13126. * Will do nothing if webVR is not supported or if there is no webVR device
  13127. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13128. */
  13129. enableVR(): void;
  13130. /** @hidden */ private _onVRFullScreenTriggered(): void;
  13131. }
  13132. }
  13133. declare module BABYLON {
  13134. /**
  13135. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13136. * IMPORTANT!! The data is right-hand data.
  13137. * @export
  13138. * @interface DevicePose
  13139. */
  13140. export interface DevicePose {
  13141. /**
  13142. * The position of the device, values in array are [x,y,z].
  13143. */
  13144. readonly position: Nullable<Float32Array>;
  13145. /**
  13146. * The linearVelocity of the device, values in array are [x,y,z].
  13147. */
  13148. readonly linearVelocity: Nullable<Float32Array>;
  13149. /**
  13150. * The linearAcceleration of the device, values in array are [x,y,z].
  13151. */
  13152. readonly linearAcceleration: Nullable<Float32Array>;
  13153. /**
  13154. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13155. */
  13156. readonly orientation: Nullable<Float32Array>;
  13157. /**
  13158. * The angularVelocity of the device, values in array are [x,y,z].
  13159. */
  13160. readonly angularVelocity: Nullable<Float32Array>;
  13161. /**
  13162. * The angularAcceleration of the device, values in array are [x,y,z].
  13163. */
  13164. readonly angularAcceleration: Nullable<Float32Array>;
  13165. }
  13166. /**
  13167. * Interface representing a pose controlled object in Babylon.
  13168. * A pose controlled object has both regular pose values as well as pose values
  13169. * from an external device such as a VR head mounted display
  13170. */
  13171. export interface PoseControlled {
  13172. /**
  13173. * The position of the object in babylon space.
  13174. */
  13175. position: Vector3;
  13176. /**
  13177. * The rotation quaternion of the object in babylon space.
  13178. */
  13179. rotationQuaternion: Quaternion;
  13180. /**
  13181. * The position of the device in babylon space.
  13182. */
  13183. devicePosition?: Vector3;
  13184. /**
  13185. * The rotation quaternion of the device in babylon space.
  13186. */
  13187. deviceRotationQuaternion: Quaternion;
  13188. /**
  13189. * The raw pose coming from the device.
  13190. */
  13191. rawPose: Nullable<DevicePose>;
  13192. /**
  13193. * The scale of the device to be used when translating from device space to babylon space.
  13194. */
  13195. deviceScaleFactor: number;
  13196. /**
  13197. * Updates the poseControlled values based on the input device pose.
  13198. * @param poseData the pose data to update the object with
  13199. */
  13200. updateFromDevice(poseData: DevicePose): void;
  13201. }
  13202. /**
  13203. * Set of options to customize the webVRCamera
  13204. */
  13205. export interface WebVROptions {
  13206. /**
  13207. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13208. */
  13209. trackPosition?: boolean;
  13210. /**
  13211. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13212. */
  13213. positionScale?: number;
  13214. /**
  13215. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13216. */
  13217. displayName?: string;
  13218. /**
  13219. * Should the native controller meshes be initialized. (default: true)
  13220. */
  13221. controllerMeshes?: boolean;
  13222. /**
  13223. * Creating a default HemiLight only on controllers. (default: true)
  13224. */
  13225. defaultLightingOnControllers?: boolean;
  13226. /**
  13227. * If you don't want to use the default VR button of the helper. (default: false)
  13228. */
  13229. useCustomVRButton?: boolean;
  13230. /**
  13231. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13232. */
  13233. customVRButton?: HTMLButtonElement;
  13234. /**
  13235. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13236. */
  13237. rayLength?: number;
  13238. /**
  13239. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13240. */
  13241. defaultHeight?: number;
  13242. /**
  13243. * If multiview should be used if availible (default: false)
  13244. */
  13245. useMultiview?: boolean;
  13246. }
  13247. /**
  13248. * This represents a WebVR camera.
  13249. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13250. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13251. */
  13252. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13253. private webVROptions;
  13254. /**
  13255. * @hidden
  13256. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13257. */ private _vrDevice: any;
  13258. /**
  13259. * The rawPose of the vrDevice.
  13260. */
  13261. rawPose: Nullable<DevicePose>;
  13262. private _onVREnabled;
  13263. private _specsVersion;
  13264. private _attached;
  13265. private _frameData;
  13266. protected _descendants: Array<Node>;
  13267. private _deviceRoomPosition;
  13268. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  13269. private _standingMatrix;
  13270. /**
  13271. * Represents device position in babylon space.
  13272. */
  13273. devicePosition: Vector3;
  13274. /**
  13275. * Represents device rotation in babylon space.
  13276. */
  13277. deviceRotationQuaternion: Quaternion;
  13278. /**
  13279. * The scale of the device to be used when translating from device space to babylon space.
  13280. */
  13281. deviceScaleFactor: number;
  13282. private _deviceToWorld;
  13283. private _worldToDevice;
  13284. /**
  13285. * References to the webVR controllers for the vrDevice.
  13286. */
  13287. controllers: Array<WebVRController>;
  13288. /**
  13289. * Emits an event when a controller is attached.
  13290. */
  13291. onControllersAttachedObservable: Observable<WebVRController[]>;
  13292. /**
  13293. * Emits an event when a controller's mesh has been loaded;
  13294. */
  13295. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13296. /**
  13297. * Emits an event when the HMD's pose has been updated.
  13298. */
  13299. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13300. private _poseSet;
  13301. /**
  13302. * If the rig cameras be used as parent instead of this camera.
  13303. */
  13304. rigParenting: boolean;
  13305. private _lightOnControllers;
  13306. private _defaultHeight?;
  13307. /**
  13308. * Instantiates a WebVRFreeCamera.
  13309. * @param name The name of the WebVRFreeCamera
  13310. * @param position The starting anchor position for the camera
  13311. * @param scene The scene the camera belongs to
  13312. * @param webVROptions a set of customizable options for the webVRCamera
  13313. */
  13314. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13315. /**
  13316. * Gets the device distance from the ground in meters.
  13317. * @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.
  13318. */
  13319. deviceDistanceToRoomGround(): number;
  13320. /**
  13321. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13322. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13323. */
  13324. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13325. /**
  13326. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13327. * @returns A promise with a boolean set to if the standing matrix is supported.
  13328. */
  13329. useStandingMatrixAsync(): Promise<boolean>;
  13330. /**
  13331. * Disposes the camera
  13332. */
  13333. dispose(): void;
  13334. /**
  13335. * Gets a vrController by name.
  13336. * @param name The name of the controller to retreive
  13337. * @returns the controller matching the name specified or null if not found
  13338. */
  13339. getControllerByName(name: string): Nullable<WebVRController>;
  13340. private _leftController;
  13341. /**
  13342. * The controller corrisponding to the users left hand.
  13343. */
  13344. readonly leftController: Nullable<WebVRController>;
  13345. private _rightController;
  13346. /**
  13347. * The controller corrisponding to the users right hand.
  13348. */
  13349. readonly rightController: Nullable<WebVRController>;
  13350. /**
  13351. * Casts a ray forward from the vrCamera's gaze.
  13352. * @param length Length of the ray (default: 100)
  13353. * @returns the ray corrisponding to the gaze
  13354. */
  13355. getForwardRay(length?: number): Ray;
  13356. /**
  13357. * @hidden
  13358. * Updates the camera based on device's frame data
  13359. */ private _checkInputs(): void;
  13360. /**
  13361. * Updates the poseControlled values based on the input device pose.
  13362. * @param poseData Pose coming from the device
  13363. */
  13364. updateFromDevice(poseData: DevicePose): void;
  13365. private _htmlElementAttached;
  13366. private _detachIfAttached;
  13367. /**
  13368. * WebVR's attach control will start broadcasting frames to the device.
  13369. * Note that in certain browsers (chrome for example) this function must be called
  13370. * within a user-interaction callback. Example:
  13371. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13372. *
  13373. * @param element html element to attach the vrDevice to
  13374. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13375. */
  13376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13377. /**
  13378. * Detaches the camera from the html element and disables VR
  13379. *
  13380. * @param element html element to detach from
  13381. */
  13382. detachControl(element: HTMLElement): void;
  13383. /**
  13384. * @returns the name of this class
  13385. */
  13386. getClassName(): string;
  13387. /**
  13388. * Calls resetPose on the vrDisplay
  13389. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13390. */
  13391. resetToCurrentRotation(): void;
  13392. /**
  13393. * @hidden
  13394. * Updates the rig cameras (left and right eye)
  13395. */ private _updateRigCameras(): void;
  13396. private _workingVector;
  13397. private _oneVector;
  13398. private _workingMatrix;
  13399. private updateCacheCalled;
  13400. private _correctPositionIfNotTrackPosition;
  13401. /**
  13402. * @hidden
  13403. * Updates the cached values of the camera
  13404. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13405. */ private _updateCache(ignoreParentClass?: boolean): void;
  13406. /**
  13407. * @hidden
  13408. * Get current device position in babylon world
  13409. */ private _computeDevicePosition(): void;
  13410. /**
  13411. * Updates the current device position and rotation in the babylon world
  13412. */
  13413. update(): void;
  13414. /**
  13415. * @hidden
  13416. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13417. * @returns an identity matrix
  13418. */ private _getViewMatrix(): Matrix;
  13419. private _tmpMatrix;
  13420. /**
  13421. * This function is called by the two RIG cameras.
  13422. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13423. * @hidden
  13424. */ private _getWebVRViewMatrix(): Matrix;
  13425. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  13426. private _onGamepadConnectedObserver;
  13427. private _onGamepadDisconnectedObserver;
  13428. private _updateCacheWhenTrackingDisabledObserver;
  13429. /**
  13430. * Initializes the controllers and their meshes
  13431. */
  13432. initControllers(): void;
  13433. }
  13434. }
  13435. declare module BABYLON {
  13436. /**
  13437. * Size options for a post process
  13438. */
  13439. export type PostProcessOptions = {
  13440. width: number;
  13441. height: number;
  13442. };
  13443. /**
  13444. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13445. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13446. */
  13447. export class PostProcess {
  13448. /** Name of the PostProcess. */
  13449. name: string;
  13450. /**
  13451. * Gets or sets the unique id of the post process
  13452. */
  13453. uniqueId: number;
  13454. /**
  13455. * Width of the texture to apply the post process on
  13456. */
  13457. width: number;
  13458. /**
  13459. * Height of the texture to apply the post process on
  13460. */
  13461. height: number;
  13462. /**
  13463. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13464. * @hidden
  13465. */ private _outputTexture: Nullable<InternalTexture>;
  13466. /**
  13467. * Sampling mode used by the shader
  13468. * See https://doc.babylonjs.com/classes/3.1/texture
  13469. */
  13470. renderTargetSamplingMode: number;
  13471. /**
  13472. * Clear color to use when screen clearing
  13473. */
  13474. clearColor: Color4;
  13475. /**
  13476. * If the buffer needs to be cleared before applying the post process. (default: true)
  13477. * Should be set to false if shader will overwrite all previous pixels.
  13478. */
  13479. autoClear: boolean;
  13480. /**
  13481. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13482. */
  13483. alphaMode: number;
  13484. /**
  13485. * Sets the setAlphaBlendConstants of the babylon engine
  13486. */
  13487. alphaConstants: Color4;
  13488. /**
  13489. * Animations to be used for the post processing
  13490. */
  13491. animations: Animation[];
  13492. /**
  13493. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13494. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13495. */
  13496. enablePixelPerfectMode: boolean;
  13497. /**
  13498. * Force the postprocess to be applied without taking in account viewport
  13499. */
  13500. forceFullscreenViewport: boolean;
  13501. /**
  13502. * List of inspectable custom properties (used by the Inspector)
  13503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13504. */
  13505. inspectableCustomProperties: IInspectable[];
  13506. /**
  13507. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13508. *
  13509. * | Value | Type | Description |
  13510. * | ----- | ----------------------------------- | ----------- |
  13511. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13512. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13513. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13514. *
  13515. */
  13516. scaleMode: number;
  13517. /**
  13518. * Force textures to be a power of two (default: false)
  13519. */
  13520. alwaysForcePOT: boolean;
  13521. private _samples;
  13522. /**
  13523. * Number of sample textures (default: 1)
  13524. */
  13525. samples: number;
  13526. /**
  13527. * Modify the scale of the post process to be the same as the viewport (default: false)
  13528. */
  13529. adaptScaleToCurrentViewport: boolean;
  13530. private _camera;
  13531. private _scene;
  13532. private _engine;
  13533. private _options;
  13534. private _reusable;
  13535. private _textureType;
  13536. /**
  13537. * Smart array of input and output textures for the post process.
  13538. * @hidden
  13539. */ private _textures: SmartArray<InternalTexture>;
  13540. /**
  13541. * The index in _textures that corresponds to the output texture.
  13542. * @hidden
  13543. */ private _currentRenderTextureInd: number;
  13544. private _effect;
  13545. private _samplers;
  13546. private _fragmentUrl;
  13547. private _vertexUrl;
  13548. private _parameters;
  13549. private _scaleRatio;
  13550. protected _indexParameters: any;
  13551. private _shareOutputWithPostProcess;
  13552. private _texelSize;
  13553. private _forcedOutputTexture;
  13554. /**
  13555. * Returns the fragment url or shader name used in the post process.
  13556. * @returns the fragment url or name in the shader store.
  13557. */
  13558. getEffectName(): string;
  13559. /**
  13560. * An event triggered when the postprocess is activated.
  13561. */
  13562. onActivateObservable: Observable<Camera>;
  13563. private _onActivateObserver;
  13564. /**
  13565. * A function that is added to the onActivateObservable
  13566. */
  13567. onActivate: Nullable<(camera: Camera) => void>;
  13568. /**
  13569. * An event triggered when the postprocess changes its size.
  13570. */
  13571. onSizeChangedObservable: Observable<PostProcess>;
  13572. private _onSizeChangedObserver;
  13573. /**
  13574. * A function that is added to the onSizeChangedObservable
  13575. */
  13576. onSizeChanged: (postProcess: PostProcess) => void;
  13577. /**
  13578. * An event triggered when the postprocess applies its effect.
  13579. */
  13580. onApplyObservable: Observable<Effect>;
  13581. private _onApplyObserver;
  13582. /**
  13583. * A function that is added to the onApplyObservable
  13584. */
  13585. onApply: (effect: Effect) => void;
  13586. /**
  13587. * An event triggered before rendering the postprocess
  13588. */
  13589. onBeforeRenderObservable: Observable<Effect>;
  13590. private _onBeforeRenderObserver;
  13591. /**
  13592. * A function that is added to the onBeforeRenderObservable
  13593. */
  13594. onBeforeRender: (effect: Effect) => void;
  13595. /**
  13596. * An event triggered after rendering the postprocess
  13597. */
  13598. onAfterRenderObservable: Observable<Effect>;
  13599. private _onAfterRenderObserver;
  13600. /**
  13601. * A function that is added to the onAfterRenderObservable
  13602. */
  13603. onAfterRender: (efect: Effect) => void;
  13604. /**
  13605. * 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
  13606. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13607. */
  13608. inputTexture: InternalTexture;
  13609. /**
  13610. * Gets the camera which post process is applied to.
  13611. * @returns The camera the post process is applied to.
  13612. */
  13613. getCamera(): Camera;
  13614. /**
  13615. * Gets the texel size of the postprocess.
  13616. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13617. */
  13618. readonly texelSize: Vector2;
  13619. /**
  13620. * Creates a new instance PostProcess
  13621. * @param name The name of the PostProcess.
  13622. * @param fragmentUrl The url of the fragment shader to be used.
  13623. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13624. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13625. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13626. * @param camera The camera to apply the render pass to.
  13627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13628. * @param engine The engine which the post process will be applied. (default: current engine)
  13629. * @param reusable If the post process can be reused on the same frame. (default: false)
  13630. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13631. * @param textureType Type of textures used when performing the post process. (default: 0)
  13632. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13633. * @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
  13634. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13635. */
  13636. constructor(
  13637. /** Name of the PostProcess. */
  13638. 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);
  13639. /**
  13640. * Gets a string idenfifying the name of the class
  13641. * @returns "PostProcess" string
  13642. */
  13643. getClassName(): string;
  13644. /**
  13645. * Gets the engine which this post process belongs to.
  13646. * @returns The engine the post process was enabled with.
  13647. */
  13648. getEngine(): Engine;
  13649. /**
  13650. * The effect that is created when initializing the post process.
  13651. * @returns The created effect corrisponding the the postprocess.
  13652. */
  13653. getEffect(): Effect;
  13654. /**
  13655. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13656. * @param postProcess The post process to share the output with.
  13657. * @returns This post process.
  13658. */
  13659. shareOutputWith(postProcess: PostProcess): PostProcess;
  13660. /**
  13661. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13662. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13663. */
  13664. useOwnOutput(): void;
  13665. /**
  13666. * Updates the effect with the current post process compile time values and recompiles the shader.
  13667. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13668. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13669. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13670. * @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
  13671. * @param onCompiled Called when the shader has been compiled.
  13672. * @param onError Called if there is an error when compiling a shader.
  13673. */
  13674. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13675. /**
  13676. * The post process is reusable if it can be used multiple times within one frame.
  13677. * @returns If the post process is reusable
  13678. */
  13679. isReusable(): boolean;
  13680. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13681. markTextureDirty(): void;
  13682. /**
  13683. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13684. * 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.
  13685. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13686. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13687. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13688. * @returns The target texture that was bound to be written to.
  13689. */
  13690. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13691. /**
  13692. * If the post process is supported.
  13693. */
  13694. readonly isSupported: boolean;
  13695. /**
  13696. * The aspect ratio of the output texture.
  13697. */
  13698. readonly aspectRatio: number;
  13699. /**
  13700. * Get a value indicating if the post-process is ready to be used
  13701. * @returns true if the post-process is ready (shader is compiled)
  13702. */
  13703. isReady(): boolean;
  13704. /**
  13705. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13706. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13707. */
  13708. apply(): Nullable<Effect>;
  13709. private _disposeTextures;
  13710. /**
  13711. * Disposes the post process.
  13712. * @param camera The camera to dispose the post process on.
  13713. */
  13714. dispose(camera?: Camera): void;
  13715. }
  13716. }
  13717. declare module BABYLON {
  13718. /**
  13719. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13721. */
  13722. export class PostProcessManager {
  13723. private _scene;
  13724. private _indexBuffer;
  13725. private _vertexBuffers;
  13726. /**
  13727. * Creates a new instance PostProcess
  13728. * @param scene The scene that the post process is associated with.
  13729. */
  13730. constructor(scene: Scene);
  13731. private _prepareBuffers;
  13732. private _buildIndexBuffer;
  13733. /**
  13734. * Rebuilds the vertex buffers of the manager.
  13735. * @hidden
  13736. */ private _rebuild(): void;
  13737. /**
  13738. * Prepares a frame to be run through a post process.
  13739. * @param sourceTexture The input texture to the post procesess. (default: null)
  13740. * @param postProcesses An array of post processes to be run. (default: null)
  13741. * @returns True if the post processes were able to be run.
  13742. * @hidden
  13743. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13744. /**
  13745. * Manually render a set of post processes to a texture.
  13746. * @param postProcesses An array of post processes to be run.
  13747. * @param targetTexture The target texture to render to.
  13748. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13749. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13750. * @param lodLevel defines which lod of the texture to render to
  13751. */
  13752. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13753. /**
  13754. * Finalize the result of the output of the postprocesses.
  13755. * @param doNotPresent If true the result will not be displayed to the screen.
  13756. * @param targetTexture The target texture to render to.
  13757. * @param faceIndex The index of the face to bind the target texture to.
  13758. * @param postProcesses The array of post processes to render.
  13759. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13760. * @hidden
  13761. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13762. /**
  13763. * Disposes of the post process manager.
  13764. */
  13765. dispose(): void;
  13766. }
  13767. }
  13768. declare module BABYLON {
  13769. interface AbstractScene {
  13770. /**
  13771. * The list of procedural textures added to the scene
  13772. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13773. */
  13774. proceduralTextures: Array<ProceduralTexture>;
  13775. }
  13776. /**
  13777. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13778. * in a given scene.
  13779. */
  13780. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13781. /**
  13782. * The component name helpfull to identify the component in the list of scene components.
  13783. */
  13784. readonly name: string;
  13785. /**
  13786. * The scene the component belongs to.
  13787. */
  13788. scene: Scene;
  13789. /**
  13790. * Creates a new instance of the component for the given scene
  13791. * @param scene Defines the scene to register the component in
  13792. */
  13793. constructor(scene: Scene);
  13794. /**
  13795. * Registers the component in a given scene
  13796. */
  13797. register(): void;
  13798. /**
  13799. * Rebuilds the elements related to this component in case of
  13800. * context lost for instance.
  13801. */
  13802. rebuild(): void;
  13803. /**
  13804. * Disposes the component and the associated ressources.
  13805. */
  13806. dispose(): void;
  13807. private _beforeClear;
  13808. }
  13809. }
  13810. declare module BABYLON {
  13811. interface Engine {
  13812. /**
  13813. * Creates a new render target cube texture
  13814. * @param size defines the size of the texture
  13815. * @param options defines the options used to create the texture
  13816. * @returns a new render target cube texture stored in an InternalTexture
  13817. */
  13818. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13819. }
  13820. }
  13821. declare module BABYLON {
  13822. /** @hidden */
  13823. export var proceduralVertexShader: {
  13824. name: string;
  13825. shader: string;
  13826. };
  13827. }
  13828. declare module BABYLON {
  13829. /**
  13830. * 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.
  13831. * This is the base class of any Procedural texture and contains most of the shareable code.
  13832. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13833. */
  13834. export class ProceduralTexture extends Texture {
  13835. isCube: boolean;
  13836. /**
  13837. * Define if the texture is enabled or not (disabled texture will not render)
  13838. */
  13839. isEnabled: boolean;
  13840. /**
  13841. * Define if the texture must be cleared before rendering (default is true)
  13842. */
  13843. autoClear: boolean;
  13844. /**
  13845. * Callback called when the texture is generated
  13846. */
  13847. onGenerated: () => void;
  13848. /**
  13849. * Event raised when the texture is generated
  13850. */
  13851. onGeneratedObservable: Observable<ProceduralTexture>;
  13852. /** @hidden */ private _generateMipMaps: boolean;
  13853. /** @hidden **/ private _effect: Effect;
  13854. /** @hidden */ private _textures: {
  13855. [key: string]: Texture;
  13856. };
  13857. private _size;
  13858. private _currentRefreshId;
  13859. private _refreshRate;
  13860. private _vertexBuffers;
  13861. private _indexBuffer;
  13862. private _uniforms;
  13863. private _samplers;
  13864. private _fragment;
  13865. private _floats;
  13866. private _ints;
  13867. private _floatsArrays;
  13868. private _colors3;
  13869. private _colors4;
  13870. private _vectors2;
  13871. private _vectors3;
  13872. private _matrices;
  13873. private _fallbackTexture;
  13874. private _fallbackTextureUsed;
  13875. private _engine;
  13876. private _cachedDefines;
  13877. private _contentUpdateId;
  13878. private _contentData;
  13879. /**
  13880. * Instantiates a new procedural texture.
  13881. * 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.
  13882. * This is the base class of any Procedural texture and contains most of the shareable code.
  13883. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13884. * @param name Define the name of the texture
  13885. * @param size Define the size of the texture to create
  13886. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13887. * @param scene Define the scene the texture belongs to
  13888. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13889. * @param generateMipMaps Define if the texture should creates mip maps or not
  13890. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13891. */
  13892. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13893. /**
  13894. * The effect that is created when initializing the post process.
  13895. * @returns The created effect corrisponding the the postprocess.
  13896. */
  13897. getEffect(): Effect;
  13898. /**
  13899. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13900. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13901. */
  13902. getContent(): Nullable<ArrayBufferView>;
  13903. private _createIndexBuffer;
  13904. /** @hidden */ private _rebuild(): void;
  13905. /**
  13906. * Resets the texture in order to recreate its associated resources.
  13907. * This can be called in case of context loss
  13908. */
  13909. reset(): void;
  13910. protected _getDefines(): string;
  13911. /**
  13912. * Is the texture ready to be used ? (rendered at least once)
  13913. * @returns true if ready, otherwise, false.
  13914. */
  13915. isReady(): boolean;
  13916. /**
  13917. * Resets the refresh counter of the texture and start bak from scratch.
  13918. * Could be useful to regenerate the texture if it is setup to render only once.
  13919. */
  13920. resetRefreshCounter(): void;
  13921. /**
  13922. * Set the fragment shader to use in order to render the texture.
  13923. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13924. */
  13925. setFragment(fragment: any): void;
  13926. /**
  13927. * Define the refresh rate of the texture or the rendering frequency.
  13928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13929. */
  13930. refreshRate: number;
  13931. /** @hidden */ private _shouldRender(): boolean;
  13932. /**
  13933. * Get the size the texture is rendering at.
  13934. * @returns the size (texture is always squared)
  13935. */
  13936. getRenderSize(): number;
  13937. /**
  13938. * Resize the texture to new value.
  13939. * @param size Define the new size the texture should have
  13940. * @param generateMipMaps Define whether the new texture should create mip maps
  13941. */
  13942. resize(size: number, generateMipMaps: boolean): void;
  13943. private _checkUniform;
  13944. /**
  13945. * Set a texture in the shader program used to render.
  13946. * @param name Define the name of the uniform samplers as defined in the shader
  13947. * @param texture Define the texture to bind to this sampler
  13948. * @return the texture itself allowing "fluent" like uniform updates
  13949. */
  13950. setTexture(name: string, texture: Texture): ProceduralTexture;
  13951. /**
  13952. * Set a float in the shader.
  13953. * @param name Define the name of the uniform as defined in the shader
  13954. * @param value Define the value to give to the uniform
  13955. * @return the texture itself allowing "fluent" like uniform updates
  13956. */
  13957. setFloat(name: string, value: number): ProceduralTexture;
  13958. /**
  13959. * Set a int in the shader.
  13960. * @param name Define the name of the uniform as defined in the shader
  13961. * @param value Define the value to give to the uniform
  13962. * @return the texture itself allowing "fluent" like uniform updates
  13963. */
  13964. setInt(name: string, value: number): ProceduralTexture;
  13965. /**
  13966. * Set an array of floats in the shader.
  13967. * @param name Define the name of the uniform as defined in the shader
  13968. * @param value Define the value to give to the uniform
  13969. * @return the texture itself allowing "fluent" like uniform updates
  13970. */
  13971. setFloats(name: string, value: number[]): ProceduralTexture;
  13972. /**
  13973. * Set a vec3 in the shader from a Color3.
  13974. * @param name Define the name of the uniform as defined in the shader
  13975. * @param value Define the value to give to the uniform
  13976. * @return the texture itself allowing "fluent" like uniform updates
  13977. */
  13978. setColor3(name: string, value: Color3): ProceduralTexture;
  13979. /**
  13980. * Set a vec4 in the shader from a Color4.
  13981. * @param name Define the name of the uniform as defined in the shader
  13982. * @param value Define the value to give to the uniform
  13983. * @return the texture itself allowing "fluent" like uniform updates
  13984. */
  13985. setColor4(name: string, value: Color4): ProceduralTexture;
  13986. /**
  13987. * Set a vec2 in the shader from a Vector2.
  13988. * @param name Define the name of the uniform as defined in the shader
  13989. * @param value Define the value to give to the uniform
  13990. * @return the texture itself allowing "fluent" like uniform updates
  13991. */
  13992. setVector2(name: string, value: Vector2): ProceduralTexture;
  13993. /**
  13994. * Set a vec3 in the shader from a Vector3.
  13995. * @param name Define the name of the uniform as defined in the shader
  13996. * @param value Define the value to give to the uniform
  13997. * @return the texture itself allowing "fluent" like uniform updates
  13998. */
  13999. setVector3(name: string, value: Vector3): ProceduralTexture;
  14000. /**
  14001. * Set a mat4 in the shader from a MAtrix.
  14002. * @param name Define the name of the uniform as defined in the shader
  14003. * @param value Define the value to give to the uniform
  14004. * @return the texture itself allowing "fluent" like uniform updates
  14005. */
  14006. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14007. /**
  14008. * Render the texture to its associated render target.
  14009. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14010. */
  14011. render(useCameraPostProcess?: boolean): void;
  14012. /**
  14013. * Clone the texture.
  14014. * @returns the cloned texture
  14015. */
  14016. clone(): ProceduralTexture;
  14017. /**
  14018. * Dispose the texture and release its asoociated resources.
  14019. */
  14020. dispose(): void;
  14021. }
  14022. }
  14023. declare module BABYLON {
  14024. /**
  14025. * This represents the base class for particle system in Babylon.
  14026. * 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.
  14027. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14028. * @example https://doc.babylonjs.com/babylon101/particles
  14029. */
  14030. export class BaseParticleSystem {
  14031. /**
  14032. * Source color is added to the destination color without alpha affecting the result
  14033. */
  14034. static BLENDMODE_ONEONE: number;
  14035. /**
  14036. * Blend current color and particle color using particle’s alpha
  14037. */
  14038. static BLENDMODE_STANDARD: number;
  14039. /**
  14040. * Add current color and particle color multiplied by particle’s alpha
  14041. */
  14042. static BLENDMODE_ADD: number;
  14043. /**
  14044. * Multiply current color with particle color
  14045. */
  14046. static BLENDMODE_MULTIPLY: number;
  14047. /**
  14048. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14049. */
  14050. static BLENDMODE_MULTIPLYADD: number;
  14051. /**
  14052. * List of animations used by the particle system.
  14053. */
  14054. animations: Animation[];
  14055. /**
  14056. * The id of the Particle system.
  14057. */
  14058. id: string;
  14059. /**
  14060. * The friendly name of the Particle system.
  14061. */
  14062. name: string;
  14063. /**
  14064. * The rendering group used by the Particle system to chose when to render.
  14065. */
  14066. renderingGroupId: number;
  14067. /**
  14068. * The emitter represents the Mesh or position we are attaching the particle system to.
  14069. */
  14070. emitter: Nullable<AbstractMesh | Vector3>;
  14071. /**
  14072. * The maximum number of particles to emit per frame
  14073. */
  14074. emitRate: number;
  14075. /**
  14076. * If you want to launch only a few particles at once, that can be done, as well.
  14077. */
  14078. manualEmitCount: number;
  14079. /**
  14080. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14081. */
  14082. updateSpeed: number;
  14083. /**
  14084. * The amount of time the particle system is running (depends of the overall update speed).
  14085. */
  14086. targetStopDuration: number;
  14087. /**
  14088. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14089. */
  14090. disposeOnStop: boolean;
  14091. /**
  14092. * Minimum power of emitting particles.
  14093. */
  14094. minEmitPower: number;
  14095. /**
  14096. * Maximum power of emitting particles.
  14097. */
  14098. maxEmitPower: number;
  14099. /**
  14100. * Minimum life time of emitting particles.
  14101. */
  14102. minLifeTime: number;
  14103. /**
  14104. * Maximum life time of emitting particles.
  14105. */
  14106. maxLifeTime: number;
  14107. /**
  14108. * Minimum Size of emitting particles.
  14109. */
  14110. minSize: number;
  14111. /**
  14112. * Maximum Size of emitting particles.
  14113. */
  14114. maxSize: number;
  14115. /**
  14116. * Minimum scale of emitting particles on X axis.
  14117. */
  14118. minScaleX: number;
  14119. /**
  14120. * Maximum scale of emitting particles on X axis.
  14121. */
  14122. maxScaleX: number;
  14123. /**
  14124. * Minimum scale of emitting particles on Y axis.
  14125. */
  14126. minScaleY: number;
  14127. /**
  14128. * Maximum scale of emitting particles on Y axis.
  14129. */
  14130. maxScaleY: number;
  14131. /**
  14132. * Gets or sets the minimal initial rotation in radians.
  14133. */
  14134. minInitialRotation: number;
  14135. /**
  14136. * Gets or sets the maximal initial rotation in radians.
  14137. */
  14138. maxInitialRotation: number;
  14139. /**
  14140. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14141. */
  14142. minAngularSpeed: number;
  14143. /**
  14144. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14145. */
  14146. maxAngularSpeed: number;
  14147. /**
  14148. * The texture used to render each particle. (this can be a spritesheet)
  14149. */
  14150. particleTexture: Nullable<Texture>;
  14151. /**
  14152. * The layer mask we are rendering the particles through.
  14153. */
  14154. layerMask: number;
  14155. /**
  14156. * This can help using your own shader to render the particle system.
  14157. * The according effect will be created
  14158. */
  14159. customShader: any;
  14160. /**
  14161. * By default particle system starts as soon as they are created. This prevents the
  14162. * automatic start to happen and let you decide when to start emitting particles.
  14163. */
  14164. preventAutoStart: boolean;
  14165. private _noiseTexture;
  14166. /**
  14167. * Gets or sets a texture used to add random noise to particle positions
  14168. */
  14169. noiseTexture: Nullable<ProceduralTexture>;
  14170. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14171. noiseStrength: Vector3;
  14172. /**
  14173. * Callback triggered when the particle animation is ending.
  14174. */
  14175. onAnimationEnd: Nullable<() => void>;
  14176. /**
  14177. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14178. */
  14179. blendMode: number;
  14180. /**
  14181. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14182. * to override the particles.
  14183. */
  14184. forceDepthWrite: boolean;
  14185. /** 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 */
  14186. preWarmCycles: number;
  14187. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14188. preWarmStepOffset: number;
  14189. /**
  14190. * 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)
  14191. */
  14192. spriteCellChangeSpeed: number;
  14193. /**
  14194. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14195. */
  14196. startSpriteCellID: number;
  14197. /**
  14198. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14199. */
  14200. endSpriteCellID: number;
  14201. /**
  14202. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14203. */
  14204. spriteCellWidth: number;
  14205. /**
  14206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14207. */
  14208. spriteCellHeight: number;
  14209. /**
  14210. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14211. */
  14212. spriteRandomStartCell: boolean;
  14213. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14214. translationPivot: Vector2;
  14215. /** @hidden */
  14216. protected _isAnimationSheetEnabled: boolean;
  14217. /**
  14218. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14219. */
  14220. beginAnimationOnStart: boolean;
  14221. /**
  14222. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14223. */
  14224. beginAnimationFrom: number;
  14225. /**
  14226. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14227. */
  14228. beginAnimationTo: number;
  14229. /**
  14230. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14231. */
  14232. beginAnimationLoop: boolean;
  14233. /**
  14234. * Gets or sets a world offset applied to all particles
  14235. */
  14236. worldOffset: Vector3;
  14237. /**
  14238. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14239. */
  14240. isAnimationSheetEnabled: boolean;
  14241. /**
  14242. * Get hosting scene
  14243. * @returns the scene
  14244. */
  14245. getScene(): Scene;
  14246. /**
  14247. * You can use gravity if you want to give an orientation to your particles.
  14248. */
  14249. gravity: Vector3;
  14250. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14251. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14252. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14253. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14254. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14255. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14256. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14257. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14258. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14259. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14260. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14261. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14262. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14263. /**
  14264. * Defines the delay in milliseconds before starting the system (0 by default)
  14265. */
  14266. startDelay: number;
  14267. /**
  14268. * Gets the current list of drag gradients.
  14269. * You must use addDragGradient and removeDragGradient to udpate this list
  14270. * @returns the list of drag gradients
  14271. */
  14272. getDragGradients(): Nullable<Array<FactorGradient>>;
  14273. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14274. limitVelocityDamping: number;
  14275. /**
  14276. * Gets the current list of limit velocity gradients.
  14277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14278. * @returns the list of limit velocity gradients
  14279. */
  14280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14281. /**
  14282. * Gets the current list of color gradients.
  14283. * You must use addColorGradient and removeColorGradient to udpate this list
  14284. * @returns the list of color gradients
  14285. */
  14286. getColorGradients(): Nullable<Array<ColorGradient>>;
  14287. /**
  14288. * Gets the current list of size gradients.
  14289. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14290. * @returns the list of size gradients
  14291. */
  14292. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14293. /**
  14294. * Gets the current list of color remap gradients.
  14295. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14296. * @returns the list of color remap gradients
  14297. */
  14298. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Gets the current list of alpha remap gradients.
  14301. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14302. * @returns the list of alpha remap gradients
  14303. */
  14304. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14305. /**
  14306. * Gets the current list of life time gradients.
  14307. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14308. * @returns the list of life time gradients
  14309. */
  14310. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Gets the current list of angular speed gradients.
  14313. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14314. * @returns the list of angular speed gradients
  14315. */
  14316. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14317. /**
  14318. * Gets the current list of velocity gradients.
  14319. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14320. * @returns the list of velocity gradients
  14321. */
  14322. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14323. /**
  14324. * Gets the current list of start size gradients.
  14325. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14326. * @returns the list of start size gradients
  14327. */
  14328. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14329. /**
  14330. * Gets the current list of emit rate gradients.
  14331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14332. * @returns the list of emit rate gradients
  14333. */
  14334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14335. /**
  14336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14337. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14338. */
  14339. direction1: Vector3;
  14340. /**
  14341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14342. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14343. */
  14344. direction2: Vector3;
  14345. /**
  14346. * 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.
  14347. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14348. */
  14349. minEmitBox: Vector3;
  14350. /**
  14351. * 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.
  14352. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14353. */
  14354. maxEmitBox: Vector3;
  14355. /**
  14356. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14357. */
  14358. color1: Color4;
  14359. /**
  14360. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14361. */
  14362. color2: Color4;
  14363. /**
  14364. * Color the particle will have at the end of its lifetime
  14365. */
  14366. colorDead: Color4;
  14367. /**
  14368. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14369. */
  14370. textureMask: Color4;
  14371. /**
  14372. * The particle emitter type defines the emitter used by the particle system.
  14373. * It can be for example box, sphere, or cone...
  14374. */
  14375. particleEmitterType: IParticleEmitterType;
  14376. /** @hidden */ private _isSubEmitter: boolean;
  14377. /**
  14378. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14379. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14380. */
  14381. billboardMode: number;
  14382. protected _isBillboardBased: boolean;
  14383. /**
  14384. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14385. */
  14386. isBillboardBased: boolean;
  14387. /**
  14388. * The scene the particle system belongs to.
  14389. */
  14390. protected _scene: Scene;
  14391. /**
  14392. * Local cache of defines for image processing.
  14393. */
  14394. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14395. /**
  14396. * Default configuration related to image processing available in the standard Material.
  14397. */
  14398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14399. /**
  14400. * Gets the image processing configuration used either in this material.
  14401. */
  14402. /**
  14403. * Sets the Default image processing configuration used either in the this material.
  14404. *
  14405. * If sets to null, the scene one is in use.
  14406. */
  14407. imageProcessingConfiguration: ImageProcessingConfiguration;
  14408. /**
  14409. * Attaches a new image processing configuration to the Standard Material.
  14410. * @param configuration
  14411. */
  14412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14413. /** @hidden */
  14414. protected _reset(): void;
  14415. /** @hidden */
  14416. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14417. /**
  14418. * Instantiates a particle system.
  14419. * 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.
  14420. * @param name The name of the particle system
  14421. */
  14422. constructor(name: string);
  14423. /**
  14424. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14427. * @returns the emitter
  14428. */
  14429. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14430. /**
  14431. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14432. * @param radius The radius of the hemisphere to emit from
  14433. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14434. * @returns the emitter
  14435. */
  14436. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14437. /**
  14438. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14439. * @param radius The radius of the sphere to emit from
  14440. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14441. * @returns the emitter
  14442. */
  14443. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14444. /**
  14445. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14446. * @param radius The radius of the sphere to emit from
  14447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14449. * @returns the emitter
  14450. */
  14451. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14452. /**
  14453. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14454. * @param radius The radius of the emission cylinder
  14455. * @param height The height of the emission cylinder
  14456. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14457. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14458. * @returns the emitter
  14459. */
  14460. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14461. /**
  14462. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14463. * @param radius The radius of the cylinder to emit from
  14464. * @param height The height of the emission cylinder
  14465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14468. * @returns the emitter
  14469. */
  14470. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14471. /**
  14472. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14473. * @param radius The radius of the cone to emit from
  14474. * @param angle The base angle of the cone
  14475. * @returns the emitter
  14476. */
  14477. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14478. /**
  14479. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14482. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14483. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14484. * @returns the emitter
  14485. */
  14486. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14487. }
  14488. }
  14489. declare module BABYLON {
  14490. /**
  14491. * Type of sub emitter
  14492. */
  14493. export enum SubEmitterType {
  14494. /**
  14495. * Attached to the particle over it's lifetime
  14496. */
  14497. ATTACHED = 0,
  14498. /**
  14499. * Created when the particle dies
  14500. */
  14501. END = 1
  14502. }
  14503. /**
  14504. * Sub emitter class used to emit particles from an existing particle
  14505. */
  14506. export class SubEmitter {
  14507. /**
  14508. * the particle system to be used by the sub emitter
  14509. */
  14510. particleSystem: ParticleSystem;
  14511. /**
  14512. * Type of the submitter (Default: END)
  14513. */
  14514. type: SubEmitterType;
  14515. /**
  14516. * 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)
  14517. * Note: This only is supported when using an emitter of type Mesh
  14518. */
  14519. inheritDirection: boolean;
  14520. /**
  14521. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14522. */
  14523. inheritedVelocityAmount: number;
  14524. /**
  14525. * Creates a sub emitter
  14526. * @param particleSystem the particle system to be used by the sub emitter
  14527. */
  14528. constructor(
  14529. /**
  14530. * the particle system to be used by the sub emitter
  14531. */
  14532. particleSystem: ParticleSystem);
  14533. /**
  14534. * Clones the sub emitter
  14535. * @returns the cloned sub emitter
  14536. */
  14537. clone(): SubEmitter;
  14538. /**
  14539. * Serialize current object to a JSON object
  14540. * @returns the serialized object
  14541. */
  14542. serialize(): any;
  14543. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14544. /**
  14545. * Creates a new SubEmitter from a serialized JSON version
  14546. * @param serializationObject defines the JSON object to read from
  14547. * @param scene defines the hosting scene
  14548. * @param rootUrl defines the rootUrl for data loading
  14549. * @returns a new SubEmitter
  14550. */
  14551. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14552. /** Release associated resources */
  14553. dispose(): void;
  14554. }
  14555. }
  14556. declare module BABYLON {
  14557. /** @hidden */
  14558. export var clipPlaneFragmentDeclaration: {
  14559. name: string;
  14560. shader: string;
  14561. };
  14562. }
  14563. declare module BABYLON {
  14564. /** @hidden */
  14565. export var imageProcessingDeclaration: {
  14566. name: string;
  14567. shader: string;
  14568. };
  14569. }
  14570. declare module BABYLON {
  14571. /** @hidden */
  14572. export var imageProcessingFunctions: {
  14573. name: string;
  14574. shader: string;
  14575. };
  14576. }
  14577. declare module BABYLON {
  14578. /** @hidden */
  14579. export var clipPlaneFragment: {
  14580. name: string;
  14581. shader: string;
  14582. };
  14583. }
  14584. declare module BABYLON {
  14585. /** @hidden */
  14586. export var particlesPixelShader: {
  14587. name: string;
  14588. shader: string;
  14589. };
  14590. }
  14591. declare module BABYLON {
  14592. /** @hidden */
  14593. export var clipPlaneVertexDeclaration: {
  14594. name: string;
  14595. shader: string;
  14596. };
  14597. }
  14598. declare module BABYLON {
  14599. /** @hidden */
  14600. export var clipPlaneVertex: {
  14601. name: string;
  14602. shader: string;
  14603. };
  14604. }
  14605. declare module BABYLON {
  14606. /** @hidden */
  14607. export var particlesVertexShader: {
  14608. name: string;
  14609. shader: string;
  14610. };
  14611. }
  14612. declare module BABYLON {
  14613. /**
  14614. * This represents a particle system in Babylon.
  14615. * 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.
  14616. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14617. * @example https://doc.babylonjs.com/babylon101/particles
  14618. */
  14619. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14620. /**
  14621. * Billboard mode will only apply to Y axis
  14622. */
  14623. static readonly BILLBOARDMODE_Y: number;
  14624. /**
  14625. * Billboard mode will apply to all axes
  14626. */
  14627. static readonly BILLBOARDMODE_ALL: number;
  14628. /**
  14629. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14630. */
  14631. static readonly BILLBOARDMODE_STRETCHED: number;
  14632. /**
  14633. * This function can be defined to provide custom update for active particles.
  14634. * This function will be called instead of regular update (age, position, color, etc.).
  14635. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14636. */
  14637. updateFunction: (particles: Particle[]) => void;
  14638. private _emitterWorldMatrix;
  14639. /**
  14640. * This function can be defined to specify initial direction for every new particle.
  14641. * It by default use the emitterType defined function
  14642. */
  14643. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14644. /**
  14645. * This function can be defined to specify initial position for every new particle.
  14646. * It by default use the emitterType defined function
  14647. */
  14648. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14649. /**
  14650. * @hidden
  14651. */ private _inheritedVelocityOffset: Vector3;
  14652. /**
  14653. * An event triggered when the system is disposed
  14654. */
  14655. onDisposeObservable: Observable<ParticleSystem>;
  14656. private _onDisposeObserver;
  14657. /**
  14658. * Sets a callback that will be triggered when the system is disposed
  14659. */
  14660. onDispose: () => void;
  14661. private _particles;
  14662. private _epsilon;
  14663. private _capacity;
  14664. private _stockParticles;
  14665. private _newPartsExcess;
  14666. private _vertexData;
  14667. private _vertexBuffer;
  14668. private _vertexBuffers;
  14669. private _spriteBuffer;
  14670. private _indexBuffer;
  14671. private _effect;
  14672. private _customEffect;
  14673. private _cachedDefines;
  14674. private _scaledColorStep;
  14675. private _colorDiff;
  14676. private _scaledDirection;
  14677. private _scaledGravity;
  14678. private _currentRenderId;
  14679. private _alive;
  14680. private _useInstancing;
  14681. private _started;
  14682. private _stopped;
  14683. private _actualFrame;
  14684. private _scaledUpdateSpeed;
  14685. private _vertexBufferSize;
  14686. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  14687. /** @hidden */ private _currentEmitRate1: number;
  14688. /** @hidden */ private _currentEmitRate2: number;
  14689. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  14690. /** @hidden */ private _currentStartSize1: number;
  14691. /** @hidden */ private _currentStartSize2: number;
  14692. private readonly _rawTextureWidth;
  14693. private _rampGradientsTexture;
  14694. private _useRampGradients;
  14695. /** Gets or sets a boolean indicating that ramp gradients must be used
  14696. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14697. */
  14698. useRampGradients: boolean;
  14699. /**
  14700. * 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.
  14701. * 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: [])
  14702. */
  14703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14704. private _subEmitters;
  14705. /**
  14706. * @hidden
  14707. * If the particle systems emitter should be disposed when the particle system is disposed
  14708. */ private _disposeEmitterOnDispose: boolean;
  14709. /**
  14710. * The current active Sub-systems, this property is used by the root particle system only.
  14711. */
  14712. activeSubSystems: Array<ParticleSystem>;
  14713. private _rootParticleSystem;
  14714. /**
  14715. * Gets the current list of active particles
  14716. */
  14717. readonly particles: Particle[];
  14718. /**
  14719. * Returns the string "ParticleSystem"
  14720. * @returns a string containing the class name
  14721. */
  14722. getClassName(): string;
  14723. /**
  14724. * Instantiates a particle system.
  14725. * 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.
  14726. * @param name The name of the particle system
  14727. * @param capacity The max number of particles alive at the same time
  14728. * @param scene The scene the particle system belongs to
  14729. * @param customEffect a custom effect used to change the way particles are rendered by default
  14730. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14731. * @param epsilon Offset used to render the particles
  14732. */
  14733. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14734. private _addFactorGradient;
  14735. private _removeFactorGradient;
  14736. /**
  14737. * Adds a new life time gradient
  14738. * @param gradient defines the gradient to use (between 0 and 1)
  14739. * @param factor defines the life time factor to affect to the specified gradient
  14740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14741. * @returns the current particle system
  14742. */
  14743. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14744. /**
  14745. * Remove a specific life time gradient
  14746. * @param gradient defines the gradient to remove
  14747. * @returns the current particle system
  14748. */
  14749. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14750. /**
  14751. * Adds a new size gradient
  14752. * @param gradient defines the gradient to use (between 0 and 1)
  14753. * @param factor defines the size factor to affect to the specified gradient
  14754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14755. * @returns the current particle system
  14756. */
  14757. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14758. /**
  14759. * Remove a specific size gradient
  14760. * @param gradient defines the gradient to remove
  14761. * @returns the current particle system
  14762. */
  14763. removeSizeGradient(gradient: number): IParticleSystem;
  14764. /**
  14765. * Adds a new color remap gradient
  14766. * @param gradient defines the gradient to use (between 0 and 1)
  14767. * @param min defines the color remap minimal range
  14768. * @param max defines the color remap maximal range
  14769. * @returns the current particle system
  14770. */
  14771. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14772. /**
  14773. * Remove a specific color remap gradient
  14774. * @param gradient defines the gradient to remove
  14775. * @returns the current particle system
  14776. */
  14777. removeColorRemapGradient(gradient: number): IParticleSystem;
  14778. /**
  14779. * Adds a new alpha remap gradient
  14780. * @param gradient defines the gradient to use (between 0 and 1)
  14781. * @param min defines the alpha remap minimal range
  14782. * @param max defines the alpha remap maximal range
  14783. * @returns the current particle system
  14784. */
  14785. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14786. /**
  14787. * Remove a specific alpha remap gradient
  14788. * @param gradient defines the gradient to remove
  14789. * @returns the current particle system
  14790. */
  14791. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Adds a new velocity gradient
  14808. * @param gradient defines the gradient to use (between 0 and 1)
  14809. * @param factor defines the velocity to affect to the specified gradient
  14810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14811. * @returns the current particle system
  14812. */
  14813. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14814. /**
  14815. * Remove a specific velocity gradient
  14816. * @param gradient defines the gradient to remove
  14817. * @returns the current particle system
  14818. */
  14819. removeVelocityGradient(gradient: number): IParticleSystem;
  14820. /**
  14821. * Adds a new limit velocity gradient
  14822. * @param gradient defines the gradient to use (between 0 and 1)
  14823. * @param factor defines the limit velocity value to affect to the specified gradient
  14824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14825. * @returns the current particle system
  14826. */
  14827. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14828. /**
  14829. * Remove a specific limit velocity gradient
  14830. * @param gradient defines the gradient to remove
  14831. * @returns the current particle system
  14832. */
  14833. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14834. /**
  14835. * Adds a new drag gradient
  14836. * @param gradient defines the gradient to use (between 0 and 1)
  14837. * @param factor defines the drag value to affect to the specified gradient
  14838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14839. * @returns the current particle system
  14840. */
  14841. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14842. /**
  14843. * Remove a specific drag gradient
  14844. * @param gradient defines the gradient to remove
  14845. * @returns the current particle system
  14846. */
  14847. removeDragGradient(gradient: number): IParticleSystem;
  14848. /**
  14849. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14850. * @param gradient defines the gradient to use (between 0 and 1)
  14851. * @param factor defines the emit rate value to affect to the specified gradient
  14852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14853. * @returns the current particle system
  14854. */
  14855. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14856. /**
  14857. * Remove a specific emit rate gradient
  14858. * @param gradient defines the gradient to remove
  14859. * @returns the current particle system
  14860. */
  14861. removeEmitRateGradient(gradient: number): IParticleSystem;
  14862. /**
  14863. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14864. * @param gradient defines the gradient to use (between 0 and 1)
  14865. * @param factor defines the start size value to affect to the specified gradient
  14866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14867. * @returns the current particle system
  14868. */
  14869. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14870. /**
  14871. * Remove a specific start size gradient
  14872. * @param gradient defines the gradient to remove
  14873. * @returns the current particle system
  14874. */
  14875. removeStartSizeGradient(gradient: number): IParticleSystem;
  14876. private _createRampGradientTexture;
  14877. /**
  14878. * Gets the current list of ramp gradients.
  14879. * You must use addRampGradient and removeRampGradient to udpate this list
  14880. * @returns the list of ramp gradients
  14881. */
  14882. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14883. /**
  14884. * Adds a new ramp gradient used to remap particle colors
  14885. * @param gradient defines the gradient to use (between 0 and 1)
  14886. * @param color defines the color to affect to the specified gradient
  14887. * @returns the current particle system
  14888. */
  14889. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14890. /**
  14891. * Remove a specific ramp gradient
  14892. * @param gradient defines the gradient to remove
  14893. * @returns the current particle system
  14894. */
  14895. removeRampGradient(gradient: number): ParticleSystem;
  14896. /**
  14897. * Adds a new color gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param color1 defines the color to affect to the specified gradient
  14900. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14901. * @returns this particle system
  14902. */
  14903. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14904. /**
  14905. * Remove a specific color gradient
  14906. * @param gradient defines the gradient to remove
  14907. * @returns this particle system
  14908. */
  14909. removeColorGradient(gradient: number): IParticleSystem;
  14910. private _fetchR;
  14911. protected _reset(): void;
  14912. private _resetEffect;
  14913. private _createVertexBuffers;
  14914. private _createIndexBuffer;
  14915. /**
  14916. * Gets the maximum number of particles active at the same time.
  14917. * @returns The max number of active particles.
  14918. */
  14919. getCapacity(): number;
  14920. /**
  14921. * Gets whether there are still active particles in the system.
  14922. * @returns True if it is alive, otherwise false.
  14923. */
  14924. isAlive(): boolean;
  14925. /**
  14926. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14927. * @returns True if it has been started, otherwise false.
  14928. */
  14929. isStarted(): boolean;
  14930. private _prepareSubEmitterInternalArray;
  14931. /**
  14932. * Starts the particle system and begins to emit
  14933. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14934. */
  14935. start(delay?: number): void;
  14936. /**
  14937. * Stops the particle system.
  14938. * @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.
  14939. */
  14940. stop(stopSubEmitters?: boolean): void;
  14941. /**
  14942. * Remove all active particles
  14943. */
  14944. reset(): void;
  14945. /**
  14946. * @hidden (for internal use only)
  14947. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14948. /**
  14949. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14950. * Its lifetime will start back at 0.
  14951. */
  14952. recycleParticle: (particle: Particle) => void;
  14953. private _stopSubEmitters;
  14954. private _createParticle;
  14955. private _removeFromRoot;
  14956. private _emitFromParticle;
  14957. private _update;
  14958. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14959. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14960. /** @hidden */
  14961. private _getEffect;
  14962. /**
  14963. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14964. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14965. */
  14966. animate(preWarmOnly?: boolean): void;
  14967. private _appendParticleVertices;
  14968. /**
  14969. * Rebuilds the particle system.
  14970. */
  14971. rebuild(): void;
  14972. /**
  14973. * Is this system ready to be used/rendered
  14974. * @return true if the system is ready
  14975. */
  14976. isReady(): boolean;
  14977. private _render;
  14978. /**
  14979. * Renders the particle system in its current state.
  14980. * @returns the current number of particles
  14981. */
  14982. render(): number;
  14983. /**
  14984. * Disposes the particle system and free the associated resources
  14985. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14986. */
  14987. dispose(disposeTexture?: boolean): void;
  14988. /**
  14989. * Clones the particle system.
  14990. * @param name The name of the cloned object
  14991. * @param newEmitter The new emitter to use
  14992. * @returns the cloned particle system
  14993. */
  14994. clone(name: string, newEmitter: any): ParticleSystem;
  14995. /**
  14996. * Serializes the particle system to a JSON object.
  14997. * @returns the JSON object
  14998. */
  14999. serialize(): any;
  15000. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15001. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15002. /**
  15003. * Parses a JSON object to create a particle system.
  15004. * @param parsedParticleSystem The JSON object to parse
  15005. * @param scene The scene to create the particle system in
  15006. * @param rootUrl The root url to use to load external dependencies like texture
  15007. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15008. * @returns the Parsed particle system
  15009. */
  15010. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15011. }
  15012. }
  15013. declare module BABYLON {
  15014. /**
  15015. * A particle represents one of the element emitted by a particle system.
  15016. * This is mainly define by its coordinates, direction, velocity and age.
  15017. */
  15018. export class Particle {
  15019. /**
  15020. * The particle system the particle belongs to.
  15021. */
  15022. particleSystem: ParticleSystem;
  15023. private static _Count;
  15024. /**
  15025. * Unique ID of the particle
  15026. */
  15027. id: number;
  15028. /**
  15029. * The world position of the particle in the scene.
  15030. */
  15031. position: Vector3;
  15032. /**
  15033. * The world direction of the particle in the scene.
  15034. */
  15035. direction: Vector3;
  15036. /**
  15037. * The color of the particle.
  15038. */
  15039. color: Color4;
  15040. /**
  15041. * The color change of the particle per step.
  15042. */
  15043. colorStep: Color4;
  15044. /**
  15045. * Defines how long will the life of the particle be.
  15046. */
  15047. lifeTime: number;
  15048. /**
  15049. * The current age of the particle.
  15050. */
  15051. age: number;
  15052. /**
  15053. * The current size of the particle.
  15054. */
  15055. size: number;
  15056. /**
  15057. * The current scale of the particle.
  15058. */
  15059. scale: Vector2;
  15060. /**
  15061. * The current angle of the particle.
  15062. */
  15063. angle: number;
  15064. /**
  15065. * Defines how fast is the angle changing.
  15066. */
  15067. angularSpeed: number;
  15068. /**
  15069. * Defines the cell index used by the particle to be rendered from a sprite.
  15070. */
  15071. cellIndex: number;
  15072. /**
  15073. * The information required to support color remapping
  15074. */
  15075. remapData: Vector4;
  15076. /** @hidden */ private _randomCellOffset?: number;
  15077. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  15078. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15079. /** @hidden */ private _initialStartSpriteCellID: number;
  15080. /** @hidden */ private _initialEndSpriteCellID: number;
  15081. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  15082. /** @hidden */ private _currentColor1: Color4;
  15083. /** @hidden */ private _currentColor2: Color4;
  15084. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  15085. /** @hidden */ private _currentSize1: number;
  15086. /** @hidden */ private _currentSize2: number;
  15087. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15088. /** @hidden */ private _currentAngularSpeed1: number;
  15089. /** @hidden */ private _currentAngularSpeed2: number;
  15090. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  15091. /** @hidden */ private _currentVelocity1: number;
  15092. /** @hidden */ private _currentVelocity2: number;
  15093. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15094. /** @hidden */ private _currentLimitVelocity1: number;
  15095. /** @hidden */ private _currentLimitVelocity2: number;
  15096. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  15097. /** @hidden */ private _currentDrag1: number;
  15098. /** @hidden */ private _currentDrag2: number;
  15099. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  15100. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  15101. /**
  15102. * Creates a new instance Particle
  15103. * @param particleSystem the particle system the particle belongs to
  15104. */
  15105. constructor(
  15106. /**
  15107. * The particle system the particle belongs to.
  15108. */
  15109. particleSystem: ParticleSystem);
  15110. private updateCellInfoFromSystem;
  15111. /**
  15112. * Defines how the sprite cell index is updated for the particle
  15113. */
  15114. updateCellIndex(): void;
  15115. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15116. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  15117. /** @hidden */ private _reset(): void;
  15118. /**
  15119. * Copy the properties of particle to another one.
  15120. * @param other the particle to copy the information to.
  15121. */
  15122. copyTo(other: Particle): void;
  15123. }
  15124. }
  15125. declare module BABYLON {
  15126. /**
  15127. * Particle emitter represents a volume emitting particles.
  15128. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15129. */
  15130. export interface IParticleEmitterType {
  15131. /**
  15132. * Called by the particle System when the direction is computed for the created particle.
  15133. * @param worldMatrix is the world matrix of the particle system
  15134. * @param directionToUpdate is the direction vector to update with the result
  15135. * @param particle is the particle we are computed the direction for
  15136. */
  15137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15138. /**
  15139. * Called by the particle System when the position is computed for the created particle.
  15140. * @param worldMatrix is the world matrix of the particle system
  15141. * @param positionToUpdate is the position vector to update with the result
  15142. * @param particle is the particle we are computed the position for
  15143. */
  15144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15145. /**
  15146. * Clones the current emitter and returns a copy of it
  15147. * @returns the new emitter
  15148. */
  15149. clone(): IParticleEmitterType;
  15150. /**
  15151. * Called by the GPUParticleSystem to setup the update shader
  15152. * @param effect defines the update shader
  15153. */
  15154. applyToShader(effect: Effect): void;
  15155. /**
  15156. * Returns a string to use to update the GPU particles update shader
  15157. * @returns the effect defines string
  15158. */
  15159. getEffectDefines(): string;
  15160. /**
  15161. * Returns a string representing the class name
  15162. * @returns a string containing the class name
  15163. */
  15164. getClassName(): string;
  15165. /**
  15166. * Serializes the particle system to a JSON object.
  15167. * @returns the JSON object
  15168. */
  15169. serialize(): any;
  15170. /**
  15171. * Parse properties from a JSON object
  15172. * @param serializationObject defines the JSON object
  15173. */
  15174. parse(serializationObject: any): void;
  15175. }
  15176. }
  15177. declare module BABYLON {
  15178. /**
  15179. * Particle emitter emitting particles from the inside of a box.
  15180. * It emits the particles randomly between 2 given directions.
  15181. */
  15182. export class BoxParticleEmitter implements IParticleEmitterType {
  15183. /**
  15184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15185. */
  15186. direction1: Vector3;
  15187. /**
  15188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15189. */
  15190. direction2: Vector3;
  15191. /**
  15192. * 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.
  15193. */
  15194. minEmitBox: Vector3;
  15195. /**
  15196. * 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.
  15197. */
  15198. maxEmitBox: Vector3;
  15199. /**
  15200. * Creates a new instance BoxParticleEmitter
  15201. */
  15202. constructor();
  15203. /**
  15204. * Called by the particle System when the direction is computed for the created particle.
  15205. * @param worldMatrix is the world matrix of the particle system
  15206. * @param directionToUpdate is the direction vector to update with the result
  15207. * @param particle is the particle we are computed the direction for
  15208. */
  15209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15210. /**
  15211. * Called by the particle System when the position is computed for the created particle.
  15212. * @param worldMatrix is the world matrix of the particle system
  15213. * @param positionToUpdate is the position vector to update with the result
  15214. * @param particle is the particle we are computed the position for
  15215. */
  15216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15217. /**
  15218. * Clones the current emitter and returns a copy of it
  15219. * @returns the new emitter
  15220. */
  15221. clone(): BoxParticleEmitter;
  15222. /**
  15223. * Called by the GPUParticleSystem to setup the update shader
  15224. * @param effect defines the update shader
  15225. */
  15226. applyToShader(effect: Effect): void;
  15227. /**
  15228. * Returns a string to use to update the GPU particles update shader
  15229. * @returns a string containng the defines string
  15230. */
  15231. getEffectDefines(): string;
  15232. /**
  15233. * Returns the string "BoxParticleEmitter"
  15234. * @returns a string containing the class name
  15235. */
  15236. getClassName(): string;
  15237. /**
  15238. * Serializes the particle system to a JSON object.
  15239. * @returns the JSON object
  15240. */
  15241. serialize(): any;
  15242. /**
  15243. * Parse properties from a JSON object
  15244. * @param serializationObject defines the JSON object
  15245. */
  15246. parse(serializationObject: any): void;
  15247. }
  15248. }
  15249. declare module BABYLON {
  15250. /**
  15251. * Particle emitter emitting particles from the inside of a cone.
  15252. * It emits the particles alongside the cone volume from the base to the particle.
  15253. * The emission direction might be randomized.
  15254. */
  15255. export class ConeParticleEmitter implements IParticleEmitterType {
  15256. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15257. directionRandomizer: number;
  15258. private _radius;
  15259. private _angle;
  15260. private _height;
  15261. /**
  15262. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15263. */
  15264. radiusRange: number;
  15265. /**
  15266. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15267. */
  15268. heightRange: number;
  15269. /**
  15270. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15271. */
  15272. emitFromSpawnPointOnly: boolean;
  15273. /**
  15274. * Gets or sets the radius of the emission cone
  15275. */
  15276. radius: number;
  15277. /**
  15278. * Gets or sets the angle of the emission cone
  15279. */
  15280. angle: number;
  15281. private _buildHeight;
  15282. /**
  15283. * Creates a new instance ConeParticleEmitter
  15284. * @param radius the radius of the emission cone (1 by default)
  15285. * @param angle the cone base angle (PI by default)
  15286. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15287. */
  15288. constructor(radius?: number, angle?: number,
  15289. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15290. directionRandomizer?: number);
  15291. /**
  15292. * Called by the particle System when the direction is computed for the created particle.
  15293. * @param worldMatrix is the world matrix of the particle system
  15294. * @param directionToUpdate is the direction vector to update with the result
  15295. * @param particle is the particle we are computed the direction for
  15296. */
  15297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15298. /**
  15299. * Called by the particle System when the position is computed for the created particle.
  15300. * @param worldMatrix is the world matrix of the particle system
  15301. * @param positionToUpdate is the position vector to update with the result
  15302. * @param particle is the particle we are computed the position for
  15303. */
  15304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15305. /**
  15306. * Clones the current emitter and returns a copy of it
  15307. * @returns the new emitter
  15308. */
  15309. clone(): ConeParticleEmitter;
  15310. /**
  15311. * Called by the GPUParticleSystem to setup the update shader
  15312. * @param effect defines the update shader
  15313. */
  15314. applyToShader(effect: Effect): void;
  15315. /**
  15316. * Returns a string to use to update the GPU particles update shader
  15317. * @returns a string containng the defines string
  15318. */
  15319. getEffectDefines(): string;
  15320. /**
  15321. * Returns the string "ConeParticleEmitter"
  15322. * @returns a string containing the class name
  15323. */
  15324. getClassName(): string;
  15325. /**
  15326. * Serializes the particle system to a JSON object.
  15327. * @returns the JSON object
  15328. */
  15329. serialize(): any;
  15330. /**
  15331. * Parse properties from a JSON object
  15332. * @param serializationObject defines the JSON object
  15333. */
  15334. parse(serializationObject: any): void;
  15335. }
  15336. }
  15337. declare module BABYLON {
  15338. /**
  15339. * Particle emitter emitting particles from the inside of a cylinder.
  15340. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15341. */
  15342. export class CylinderParticleEmitter implements IParticleEmitterType {
  15343. /**
  15344. * The radius of the emission cylinder.
  15345. */
  15346. radius: number;
  15347. /**
  15348. * The height of the emission cylinder.
  15349. */
  15350. height: number;
  15351. /**
  15352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15353. */
  15354. radiusRange: number;
  15355. /**
  15356. * How much to randomize the particle direction [0-1].
  15357. */
  15358. directionRandomizer: number;
  15359. /**
  15360. * Creates a new instance CylinderParticleEmitter
  15361. * @param radius the radius of the emission cylinder (1 by default)
  15362. * @param height the height of the emission cylinder (1 by default)
  15363. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15364. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15365. */
  15366. constructor(
  15367. /**
  15368. * The radius of the emission cylinder.
  15369. */
  15370. radius?: number,
  15371. /**
  15372. * The height of the emission cylinder.
  15373. */
  15374. height?: number,
  15375. /**
  15376. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15377. */
  15378. radiusRange?: number,
  15379. /**
  15380. * How much to randomize the particle direction [0-1].
  15381. */
  15382. directionRandomizer?: number);
  15383. /**
  15384. * Called by the particle System when the direction is computed for the created particle.
  15385. * @param worldMatrix is the world matrix of the particle system
  15386. * @param directionToUpdate is the direction vector to update with the result
  15387. * @param particle is the particle we are computed the direction for
  15388. */
  15389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15390. /**
  15391. * Called by the particle System when the position is computed for the created particle.
  15392. * @param worldMatrix is the world matrix of the particle system
  15393. * @param positionToUpdate is the position vector to update with the result
  15394. * @param particle is the particle we are computed the position for
  15395. */
  15396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15397. /**
  15398. * Clones the current emitter and returns a copy of it
  15399. * @returns the new emitter
  15400. */
  15401. clone(): CylinderParticleEmitter;
  15402. /**
  15403. * Called by the GPUParticleSystem to setup the update shader
  15404. * @param effect defines the update shader
  15405. */
  15406. applyToShader(effect: Effect): void;
  15407. /**
  15408. * Returns a string to use to update the GPU particles update shader
  15409. * @returns a string containng the defines string
  15410. */
  15411. getEffectDefines(): string;
  15412. /**
  15413. * Returns the string "CylinderParticleEmitter"
  15414. * @returns a string containing the class name
  15415. */
  15416. getClassName(): string;
  15417. /**
  15418. * Serializes the particle system to a JSON object.
  15419. * @returns the JSON object
  15420. */
  15421. serialize(): any;
  15422. /**
  15423. * Parse properties from a JSON object
  15424. * @param serializationObject defines the JSON object
  15425. */
  15426. parse(serializationObject: any): void;
  15427. }
  15428. /**
  15429. * Particle emitter emitting particles from the inside of a cylinder.
  15430. * It emits the particles randomly between two vectors.
  15431. */
  15432. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15433. /**
  15434. * The min limit of the emission direction.
  15435. */
  15436. direction1: Vector3;
  15437. /**
  15438. * The max limit of the emission direction.
  15439. */
  15440. direction2: Vector3;
  15441. /**
  15442. * Creates a new instance CylinderDirectedParticleEmitter
  15443. * @param radius the radius of the emission cylinder (1 by default)
  15444. * @param height the height of the emission cylinder (1 by default)
  15445. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15446. * @param direction1 the min limit of the emission direction (up vector by default)
  15447. * @param direction2 the max limit of the emission direction (up vector by default)
  15448. */
  15449. constructor(radius?: number, height?: number, radiusRange?: number,
  15450. /**
  15451. * The min limit of the emission direction.
  15452. */
  15453. direction1?: Vector3,
  15454. /**
  15455. * The max limit of the emission direction.
  15456. */
  15457. direction2?: Vector3);
  15458. /**
  15459. * Called by the particle System when the direction is computed for the created particle.
  15460. * @param worldMatrix is the world matrix of the particle system
  15461. * @param directionToUpdate is the direction vector to update with the result
  15462. * @param particle is the particle we are computed the direction for
  15463. */
  15464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15465. /**
  15466. * Clones the current emitter and returns a copy of it
  15467. * @returns the new emitter
  15468. */
  15469. clone(): CylinderDirectedParticleEmitter;
  15470. /**
  15471. * Called by the GPUParticleSystem to setup the update shader
  15472. * @param effect defines the update shader
  15473. */
  15474. applyToShader(effect: Effect): void;
  15475. /**
  15476. * Returns a string to use to update the GPU particles update shader
  15477. * @returns a string containng the defines string
  15478. */
  15479. getEffectDefines(): string;
  15480. /**
  15481. * Returns the string "CylinderDirectedParticleEmitter"
  15482. * @returns a string containing the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Serializes the particle system to a JSON object.
  15487. * @returns the JSON object
  15488. */
  15489. serialize(): any;
  15490. /**
  15491. * Parse properties from a JSON object
  15492. * @param serializationObject defines the JSON object
  15493. */
  15494. parse(serializationObject: any): void;
  15495. }
  15496. }
  15497. declare module BABYLON {
  15498. /**
  15499. * Particle emitter emitting particles from the inside of a hemisphere.
  15500. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15501. */
  15502. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15503. /**
  15504. * The radius of the emission hemisphere.
  15505. */
  15506. radius: number;
  15507. /**
  15508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15509. */
  15510. radiusRange: number;
  15511. /**
  15512. * How much to randomize the particle direction [0-1].
  15513. */
  15514. directionRandomizer: number;
  15515. /**
  15516. * Creates a new instance HemisphericParticleEmitter
  15517. * @param radius the radius of the emission hemisphere (1 by default)
  15518. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15519. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15520. */
  15521. constructor(
  15522. /**
  15523. * The radius of the emission hemisphere.
  15524. */
  15525. radius?: number,
  15526. /**
  15527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15528. */
  15529. radiusRange?: number,
  15530. /**
  15531. * How much to randomize the particle direction [0-1].
  15532. */
  15533. directionRandomizer?: number);
  15534. /**
  15535. * Called by the particle System when the direction is computed for the created particle.
  15536. * @param worldMatrix is the world matrix of the particle system
  15537. * @param directionToUpdate is the direction vector to update with the result
  15538. * @param particle is the particle we are computed the direction for
  15539. */
  15540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15541. /**
  15542. * Called by the particle System when the position is computed for the created particle.
  15543. * @param worldMatrix is the world matrix of the particle system
  15544. * @param positionToUpdate is the position vector to update with the result
  15545. * @param particle is the particle we are computed the position for
  15546. */
  15547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15548. /**
  15549. * Clones the current emitter and returns a copy of it
  15550. * @returns the new emitter
  15551. */
  15552. clone(): HemisphericParticleEmitter;
  15553. /**
  15554. * Called by the GPUParticleSystem to setup the update shader
  15555. * @param effect defines the update shader
  15556. */
  15557. applyToShader(effect: Effect): void;
  15558. /**
  15559. * Returns a string to use to update the GPU particles update shader
  15560. * @returns a string containng the defines string
  15561. */
  15562. getEffectDefines(): string;
  15563. /**
  15564. * Returns the string "HemisphericParticleEmitter"
  15565. * @returns a string containing the class name
  15566. */
  15567. getClassName(): string;
  15568. /**
  15569. * Serializes the particle system to a JSON object.
  15570. * @returns the JSON object
  15571. */
  15572. serialize(): any;
  15573. /**
  15574. * Parse properties from a JSON object
  15575. * @param serializationObject defines the JSON object
  15576. */
  15577. parse(serializationObject: any): void;
  15578. }
  15579. }
  15580. declare module BABYLON {
  15581. /**
  15582. * Particle emitter emitting particles from a point.
  15583. * It emits the particles randomly between 2 given directions.
  15584. */
  15585. export class PointParticleEmitter implements IParticleEmitterType {
  15586. /**
  15587. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15588. */
  15589. direction1: Vector3;
  15590. /**
  15591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15592. */
  15593. direction2: Vector3;
  15594. /**
  15595. * Creates a new instance PointParticleEmitter
  15596. */
  15597. constructor();
  15598. /**
  15599. * Called by the particle System when the direction is computed for the created particle.
  15600. * @param worldMatrix is the world matrix of the particle system
  15601. * @param directionToUpdate is the direction vector to update with the result
  15602. * @param particle is the particle we are computed the direction for
  15603. */
  15604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15605. /**
  15606. * Called by the particle System when the position is computed for the created particle.
  15607. * @param worldMatrix is the world matrix of the particle system
  15608. * @param positionToUpdate is the position vector to update with the result
  15609. * @param particle is the particle we are computed the position for
  15610. */
  15611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15612. /**
  15613. * Clones the current emitter and returns a copy of it
  15614. * @returns the new emitter
  15615. */
  15616. clone(): PointParticleEmitter;
  15617. /**
  15618. * Called by the GPUParticleSystem to setup the update shader
  15619. * @param effect defines the update shader
  15620. */
  15621. applyToShader(effect: Effect): void;
  15622. /**
  15623. * Returns a string to use to update the GPU particles update shader
  15624. * @returns a string containng the defines string
  15625. */
  15626. getEffectDefines(): string;
  15627. /**
  15628. * Returns the string "PointParticleEmitter"
  15629. * @returns a string containing the class name
  15630. */
  15631. getClassName(): string;
  15632. /**
  15633. * Serializes the particle system to a JSON object.
  15634. * @returns the JSON object
  15635. */
  15636. serialize(): any;
  15637. /**
  15638. * Parse properties from a JSON object
  15639. * @param serializationObject defines the JSON object
  15640. */
  15641. parse(serializationObject: any): void;
  15642. }
  15643. }
  15644. declare module BABYLON {
  15645. /**
  15646. * Particle emitter emitting particles from the inside of a sphere.
  15647. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15648. */
  15649. export class SphereParticleEmitter implements IParticleEmitterType {
  15650. /**
  15651. * The radius of the emission sphere.
  15652. */
  15653. radius: number;
  15654. /**
  15655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15656. */
  15657. radiusRange: number;
  15658. /**
  15659. * How much to randomize the particle direction [0-1].
  15660. */
  15661. directionRandomizer: number;
  15662. /**
  15663. * Creates a new instance SphereParticleEmitter
  15664. * @param radius the radius of the emission sphere (1 by default)
  15665. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15666. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15667. */
  15668. constructor(
  15669. /**
  15670. * The radius of the emission sphere.
  15671. */
  15672. radius?: number,
  15673. /**
  15674. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15675. */
  15676. radiusRange?: number,
  15677. /**
  15678. * How much to randomize the particle direction [0-1].
  15679. */
  15680. directionRandomizer?: number);
  15681. /**
  15682. * Called by the particle System when the direction is computed for the created particle.
  15683. * @param worldMatrix is the world matrix of the particle system
  15684. * @param directionToUpdate is the direction vector to update with the result
  15685. * @param particle is the particle we are computed the direction for
  15686. */
  15687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15688. /**
  15689. * Called by the particle System when the position is computed for the created particle.
  15690. * @param worldMatrix is the world matrix of the particle system
  15691. * @param positionToUpdate is the position vector to update with the result
  15692. * @param particle is the particle we are computed the position for
  15693. */
  15694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15695. /**
  15696. * Clones the current emitter and returns a copy of it
  15697. * @returns the new emitter
  15698. */
  15699. clone(): SphereParticleEmitter;
  15700. /**
  15701. * Called by the GPUParticleSystem to setup the update shader
  15702. * @param effect defines the update shader
  15703. */
  15704. applyToShader(effect: Effect): void;
  15705. /**
  15706. * Returns a string to use to update the GPU particles update shader
  15707. * @returns a string containng the defines string
  15708. */
  15709. getEffectDefines(): string;
  15710. /**
  15711. * Returns the string "SphereParticleEmitter"
  15712. * @returns a string containing the class name
  15713. */
  15714. getClassName(): string;
  15715. /**
  15716. * Serializes the particle system to a JSON object.
  15717. * @returns the JSON object
  15718. */
  15719. serialize(): any;
  15720. /**
  15721. * Parse properties from a JSON object
  15722. * @param serializationObject defines the JSON object
  15723. */
  15724. parse(serializationObject: any): void;
  15725. }
  15726. /**
  15727. * Particle emitter emitting particles from the inside of a sphere.
  15728. * It emits the particles randomly between two vectors.
  15729. */
  15730. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15731. /**
  15732. * The min limit of the emission direction.
  15733. */
  15734. direction1: Vector3;
  15735. /**
  15736. * The max limit of the emission direction.
  15737. */
  15738. direction2: Vector3;
  15739. /**
  15740. * Creates a new instance SphereDirectedParticleEmitter
  15741. * @param radius the radius of the emission sphere (1 by default)
  15742. * @param direction1 the min limit of the emission direction (up vector by default)
  15743. * @param direction2 the max limit of the emission direction (up vector by default)
  15744. */
  15745. constructor(radius?: number,
  15746. /**
  15747. * The min limit of the emission direction.
  15748. */
  15749. direction1?: Vector3,
  15750. /**
  15751. * The max limit of the emission direction.
  15752. */
  15753. direction2?: Vector3);
  15754. /**
  15755. * Called by the particle System when the direction is computed for the created particle.
  15756. * @param worldMatrix is the world matrix of the particle system
  15757. * @param directionToUpdate is the direction vector to update with the result
  15758. * @param particle is the particle we are computed the direction for
  15759. */
  15760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15761. /**
  15762. * Clones the current emitter and returns a copy of it
  15763. * @returns the new emitter
  15764. */
  15765. clone(): SphereDirectedParticleEmitter;
  15766. /**
  15767. * Called by the GPUParticleSystem to setup the update shader
  15768. * @param effect defines the update shader
  15769. */
  15770. applyToShader(effect: Effect): void;
  15771. /**
  15772. * Returns a string to use to update the GPU particles update shader
  15773. * @returns a string containng the defines string
  15774. */
  15775. getEffectDefines(): string;
  15776. /**
  15777. * Returns the string "SphereDirectedParticleEmitter"
  15778. * @returns a string containing the class name
  15779. */
  15780. getClassName(): string;
  15781. /**
  15782. * Serializes the particle system to a JSON object.
  15783. * @returns the JSON object
  15784. */
  15785. serialize(): any;
  15786. /**
  15787. * Parse properties from a JSON object
  15788. * @param serializationObject defines the JSON object
  15789. */
  15790. parse(serializationObject: any): void;
  15791. }
  15792. }
  15793. declare module BABYLON {
  15794. /**
  15795. * Interface representing a particle system in Babylon.js.
  15796. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15797. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15798. */
  15799. export interface IParticleSystem {
  15800. /**
  15801. * List of animations used by the particle system.
  15802. */
  15803. animations: Animation[];
  15804. /**
  15805. * The id of the Particle system.
  15806. */
  15807. id: string;
  15808. /**
  15809. * The name of the Particle system.
  15810. */
  15811. name: string;
  15812. /**
  15813. * The emitter represents the Mesh or position we are attaching the particle system to.
  15814. */
  15815. emitter: Nullable<AbstractMesh | Vector3>;
  15816. /**
  15817. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15818. */
  15819. isBillboardBased: boolean;
  15820. /**
  15821. * The rendering group used by the Particle system to chose when to render.
  15822. */
  15823. renderingGroupId: number;
  15824. /**
  15825. * The layer mask we are rendering the particles through.
  15826. */
  15827. layerMask: number;
  15828. /**
  15829. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15830. */
  15831. updateSpeed: number;
  15832. /**
  15833. * The amount of time the particle system is running (depends of the overall update speed).
  15834. */
  15835. targetStopDuration: number;
  15836. /**
  15837. * The texture used to render each particle. (this can be a spritesheet)
  15838. */
  15839. particleTexture: Nullable<Texture>;
  15840. /**
  15841. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15842. */
  15843. blendMode: number;
  15844. /**
  15845. * Minimum life time of emitting particles.
  15846. */
  15847. minLifeTime: number;
  15848. /**
  15849. * Maximum life time of emitting particles.
  15850. */
  15851. maxLifeTime: number;
  15852. /**
  15853. * Minimum Size of emitting particles.
  15854. */
  15855. minSize: number;
  15856. /**
  15857. * Maximum Size of emitting particles.
  15858. */
  15859. maxSize: number;
  15860. /**
  15861. * Minimum scale of emitting particles on X axis.
  15862. */
  15863. minScaleX: number;
  15864. /**
  15865. * Maximum scale of emitting particles on X axis.
  15866. */
  15867. maxScaleX: number;
  15868. /**
  15869. * Minimum scale of emitting particles on Y axis.
  15870. */
  15871. minScaleY: number;
  15872. /**
  15873. * Maximum scale of emitting particles on Y axis.
  15874. */
  15875. maxScaleY: number;
  15876. /**
  15877. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15878. */
  15879. color1: Color4;
  15880. /**
  15881. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15882. */
  15883. color2: Color4;
  15884. /**
  15885. * Color the particle will have at the end of its lifetime.
  15886. */
  15887. colorDead: Color4;
  15888. /**
  15889. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15890. */
  15891. emitRate: number;
  15892. /**
  15893. * You can use gravity if you want to give an orientation to your particles.
  15894. */
  15895. gravity: Vector3;
  15896. /**
  15897. * Minimum power of emitting particles.
  15898. */
  15899. minEmitPower: number;
  15900. /**
  15901. * Maximum power of emitting particles.
  15902. */
  15903. maxEmitPower: number;
  15904. /**
  15905. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15906. */
  15907. minAngularSpeed: number;
  15908. /**
  15909. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15910. */
  15911. maxAngularSpeed: number;
  15912. /**
  15913. * Gets or sets the minimal initial rotation in radians.
  15914. */
  15915. minInitialRotation: number;
  15916. /**
  15917. * Gets or sets the maximal initial rotation in radians.
  15918. */
  15919. maxInitialRotation: number;
  15920. /**
  15921. * The particle emitter type defines the emitter used by the particle system.
  15922. * It can be for example box, sphere, or cone...
  15923. */
  15924. particleEmitterType: Nullable<IParticleEmitterType>;
  15925. /**
  15926. * Defines the delay in milliseconds before starting the system (0 by default)
  15927. */
  15928. startDelay: number;
  15929. /**
  15930. * 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
  15931. */
  15932. preWarmCycles: number;
  15933. /**
  15934. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15935. */
  15936. preWarmStepOffset: number;
  15937. /**
  15938. * 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)
  15939. */
  15940. spriteCellChangeSpeed: number;
  15941. /**
  15942. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15943. */
  15944. startSpriteCellID: number;
  15945. /**
  15946. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15947. */
  15948. endSpriteCellID: number;
  15949. /**
  15950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15951. */
  15952. spriteCellWidth: number;
  15953. /**
  15954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15955. */
  15956. spriteCellHeight: number;
  15957. /**
  15958. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15959. */
  15960. spriteRandomStartCell: boolean;
  15961. /**
  15962. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15963. */
  15964. isAnimationSheetEnabled: boolean;
  15965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15966. translationPivot: Vector2;
  15967. /**
  15968. * Gets or sets a texture used to add random noise to particle positions
  15969. */
  15970. noiseTexture: Nullable<BaseTexture>;
  15971. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15972. noiseStrength: Vector3;
  15973. /**
  15974. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15975. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15976. */
  15977. billboardMode: number;
  15978. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15979. limitVelocityDamping: number;
  15980. /**
  15981. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15982. */
  15983. beginAnimationOnStart: boolean;
  15984. /**
  15985. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15986. */
  15987. beginAnimationFrom: number;
  15988. /**
  15989. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15990. */
  15991. beginAnimationTo: number;
  15992. /**
  15993. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15994. */
  15995. beginAnimationLoop: boolean;
  15996. /**
  15997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15998. */
  15999. disposeOnStop: boolean;
  16000. /**
  16001. * Gets the maximum number of particles active at the same time.
  16002. * @returns The max number of active particles.
  16003. */
  16004. getCapacity(): number;
  16005. /**
  16006. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16007. * @returns True if it has been started, otherwise false.
  16008. */
  16009. isStarted(): boolean;
  16010. /**
  16011. * Animates the particle system for this frame.
  16012. */
  16013. animate(): void;
  16014. /**
  16015. * Renders the particle system in its current state.
  16016. * @returns the current number of particles
  16017. */
  16018. render(): number;
  16019. /**
  16020. * Dispose the particle system and frees its associated resources.
  16021. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16022. */
  16023. dispose(disposeTexture?: boolean): void;
  16024. /**
  16025. * Clones the particle system.
  16026. * @param name The name of the cloned object
  16027. * @param newEmitter The new emitter to use
  16028. * @returns the cloned particle system
  16029. */
  16030. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16031. /**
  16032. * Serializes the particle system to a JSON object.
  16033. * @returns the JSON object
  16034. */
  16035. serialize(): any;
  16036. /**
  16037. * Rebuild the particle system
  16038. */
  16039. rebuild(): void;
  16040. /**
  16041. * Starts the particle system and begins to emit
  16042. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16043. */
  16044. start(delay?: number): void;
  16045. /**
  16046. * Stops the particle system.
  16047. */
  16048. stop(): void;
  16049. /**
  16050. * Remove all active particles
  16051. */
  16052. reset(): void;
  16053. /**
  16054. * Is this system ready to be used/rendered
  16055. * @return true if the system is ready
  16056. */
  16057. isReady(): boolean;
  16058. /**
  16059. * Adds a new color gradient
  16060. * @param gradient defines the gradient to use (between 0 and 1)
  16061. * @param color1 defines the color to affect to the specified gradient
  16062. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16063. * @returns the current particle system
  16064. */
  16065. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16066. /**
  16067. * Remove a specific color gradient
  16068. * @param gradient defines the gradient to remove
  16069. * @returns the current particle system
  16070. */
  16071. removeColorGradient(gradient: number): IParticleSystem;
  16072. /**
  16073. * Adds a new size gradient
  16074. * @param gradient defines the gradient to use (between 0 and 1)
  16075. * @param factor defines the size factor to affect to the specified gradient
  16076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16077. * @returns the current particle system
  16078. */
  16079. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16080. /**
  16081. * Remove a specific size gradient
  16082. * @param gradient defines the gradient to remove
  16083. * @returns the current particle system
  16084. */
  16085. removeSizeGradient(gradient: number): IParticleSystem;
  16086. /**
  16087. * Gets the current list of color gradients.
  16088. * You must use addColorGradient and removeColorGradient to udpate this list
  16089. * @returns the list of color gradients
  16090. */
  16091. getColorGradients(): Nullable<Array<ColorGradient>>;
  16092. /**
  16093. * Gets the current list of size gradients.
  16094. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16095. * @returns the list of size gradients
  16096. */
  16097. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16098. /**
  16099. * Gets the current list of angular speed gradients.
  16100. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16101. * @returns the list of angular speed gradients
  16102. */
  16103. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16104. /**
  16105. * Adds a new angular speed gradient
  16106. * @param gradient defines the gradient to use (between 0 and 1)
  16107. * @param factor defines the angular speed to affect to the specified gradient
  16108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16109. * @returns the current particle system
  16110. */
  16111. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16112. /**
  16113. * Remove a specific angular speed gradient
  16114. * @param gradient defines the gradient to remove
  16115. * @returns the current particle system
  16116. */
  16117. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16118. /**
  16119. * Gets the current list of velocity gradients.
  16120. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16121. * @returns the list of velocity gradients
  16122. */
  16123. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16124. /**
  16125. * Adds a new velocity gradient
  16126. * @param gradient defines the gradient to use (between 0 and 1)
  16127. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16132. /**
  16133. * Remove a specific velocity gradient
  16134. * @param gradient defines the gradient to remove
  16135. * @returns the current particle system
  16136. */
  16137. removeVelocityGradient(gradient: number): IParticleSystem;
  16138. /**
  16139. * Gets the current list of limit velocity gradients.
  16140. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16141. * @returns the list of limit velocity gradients
  16142. */
  16143. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16144. /**
  16145. * Adds a new limit velocity gradient
  16146. * @param gradient defines the gradient to use (between 0 and 1)
  16147. * @param factor defines the limit 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16152. /**
  16153. * Remove a specific limit velocity gradient
  16154. * @param gradient defines the gradient to remove
  16155. * @returns the current particle system
  16156. */
  16157. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16158. /**
  16159. * Adds a new drag gradient
  16160. * @param gradient defines the gradient to use (between 0 and 1)
  16161. * @param factor defines the drag to affect to the specified gradient
  16162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16163. * @returns the current particle system
  16164. */
  16165. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16166. /**
  16167. * Remove a specific drag gradient
  16168. * @param gradient defines the gradient to remove
  16169. * @returns the current particle system
  16170. */
  16171. removeDragGradient(gradient: number): IParticleSystem;
  16172. /**
  16173. * Gets the current list of drag gradients.
  16174. * You must use addDragGradient and removeDragGradient to udpate this list
  16175. * @returns the list of drag gradients
  16176. */
  16177. getDragGradients(): Nullable<Array<FactorGradient>>;
  16178. /**
  16179. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16180. * @param gradient defines the gradient to use (between 0 and 1)
  16181. * @param factor defines the emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16186. /**
  16187. * Remove a specific emit rate gradient
  16188. * @param gradient defines the gradient to remove
  16189. * @returns the current particle system
  16190. */
  16191. removeEmitRateGradient(gradient: number): IParticleSystem;
  16192. /**
  16193. * Gets the current list of emit rate gradients.
  16194. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16195. * @returns the list of emit rate gradients
  16196. */
  16197. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16198. /**
  16199. * Adds a new start size 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 start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16206. /**
  16207. * Remove a specific start size gradient
  16208. * @param gradient defines the gradient to remove
  16209. * @returns the current particle system
  16210. */
  16211. removeStartSizeGradient(gradient: number): IParticleSystem;
  16212. /**
  16213. * Gets the current list of start size gradients.
  16214. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16215. * @returns the list of start size gradients
  16216. */
  16217. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16218. /**
  16219. * Adds a new life time gradient
  16220. * @param gradient defines the gradient to use (between 0 and 1)
  16221. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16226. /**
  16227. * Remove a specific life time gradient
  16228. * @param gradient defines the gradient to remove
  16229. * @returns the current particle system
  16230. */
  16231. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16232. /**
  16233. * Gets the current list of life time gradients.
  16234. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16235. * @returns the list of life time gradients
  16236. */
  16237. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16238. /**
  16239. * Gets the current list of color gradients.
  16240. * You must use addColorGradient and removeColorGradient to udpate this list
  16241. * @returns the list of color gradients
  16242. */
  16243. getColorGradients(): Nullable<Array<ColorGradient>>;
  16244. /**
  16245. * Adds a new ramp gradient used to remap particle colors
  16246. * @param gradient defines the gradient to use (between 0 and 1)
  16247. * @param color defines the color to affect to the specified gradient
  16248. * @returns the current particle system
  16249. */
  16250. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16251. /**
  16252. * Gets the current list of ramp gradients.
  16253. * You must use addRampGradient and removeRampGradient to udpate this list
  16254. * @returns the list of ramp gradients
  16255. */
  16256. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16257. /** Gets or sets a boolean indicating that ramp gradients must be used
  16258. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16259. */
  16260. useRampGradients: boolean;
  16261. /**
  16262. * Adds a new color remap gradient
  16263. * @param gradient defines the gradient to use (between 0 and 1)
  16264. * @param min defines the color remap minimal range
  16265. * @param max defines the color remap maximal range
  16266. * @returns the current particle system
  16267. */
  16268. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16269. /**
  16270. * Gets the current list of color remap gradients.
  16271. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16272. * @returns the list of color remap gradients
  16273. */
  16274. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16275. /**
  16276. * Adds a new alpha remap gradient
  16277. * @param gradient defines the gradient to use (between 0 and 1)
  16278. * @param min defines the alpha remap minimal range
  16279. * @param max defines the alpha remap maximal range
  16280. * @returns the current particle system
  16281. */
  16282. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16283. /**
  16284. * Gets the current list of alpha remap gradients.
  16285. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16286. * @returns the list of alpha remap gradients
  16287. */
  16288. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16289. /**
  16290. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16293. * @returns the emitter
  16294. */
  16295. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16296. /**
  16297. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16298. * @param radius The radius of the hemisphere to emit from
  16299. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16300. * @returns the emitter
  16301. */
  16302. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16303. /**
  16304. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16305. * @param radius The radius of the sphere to emit from
  16306. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16307. * @returns the emitter
  16308. */
  16309. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16310. /**
  16311. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16312. * @param radius The radius of the sphere to emit from
  16313. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16314. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16315. * @returns the emitter
  16316. */
  16317. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16318. /**
  16319. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16320. * @param radius The radius of the emission cylinder
  16321. * @param height The height of the emission cylinder
  16322. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16323. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16324. * @returns the emitter
  16325. */
  16326. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16327. /**
  16328. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16329. * @param radius The radius of the cylinder to emit from
  16330. * @param height The height of the emission cylinder
  16331. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16334. * @returns the emitter
  16335. */
  16336. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16337. /**
  16338. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16339. * @param radius The radius of the cone to emit from
  16340. * @param angle The base angle of the cone
  16341. * @returns the emitter
  16342. */
  16343. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16344. /**
  16345. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16346. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16347. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16348. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16349. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16350. * @returns the emitter
  16351. */
  16352. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16353. /**
  16354. * Get hosting scene
  16355. * @returns the scene
  16356. */
  16357. getScene(): Scene;
  16358. }
  16359. }
  16360. declare module BABYLON {
  16361. /**
  16362. * Creates an instance based on a source mesh.
  16363. */
  16364. export class InstancedMesh extends AbstractMesh {
  16365. private _sourceMesh;
  16366. private _currentLOD;
  16367. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  16368. constructor(name: string, source: Mesh);
  16369. /**
  16370. * Returns the string "InstancedMesh".
  16371. */
  16372. getClassName(): string;
  16373. /** Gets the list of lights affecting that mesh */
  16374. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  16375. /**
  16376. * If the source mesh receives shadows
  16377. */
  16378. readonly receiveShadows: boolean;
  16379. /**
  16380. * The material of the source mesh
  16381. */
  16382. readonly material: Nullable<Material>;
  16383. /**
  16384. * Visibility of the source mesh
  16385. */
  16386. readonly visibility: number;
  16387. /**
  16388. * Skeleton of the source mesh
  16389. */
  16390. readonly skeleton: Nullable<Skeleton>;
  16391. /**
  16392. * Rendering ground id of the source mesh
  16393. */
  16394. renderingGroupId: number;
  16395. /**
  16396. * Returns the total number of vertices (integer).
  16397. */
  16398. getTotalVertices(): number;
  16399. /**
  16400. * Returns a positive integer : the total number of indices in this mesh geometry.
  16401. * @returns the numner of indices or zero if the mesh has no geometry.
  16402. */
  16403. getTotalIndices(): number;
  16404. /**
  16405. * The source mesh of the instance
  16406. */
  16407. readonly sourceMesh: Mesh;
  16408. /**
  16409. * Is this node ready to be used/rendered
  16410. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16411. * @return {boolean} is it ready
  16412. */
  16413. isReady(completeCheck?: boolean): boolean;
  16414. /**
  16415. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16416. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16417. * @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.
  16418. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16419. */
  16420. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16421. /**
  16422. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16423. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16424. * The `data` are either a numeric array either a Float32Array.
  16425. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16426. * 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).
  16427. * Note that a new underlying VertexBuffer object is created each call.
  16428. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16429. *
  16430. * Possible `kind` values :
  16431. * - VertexBuffer.PositionKind
  16432. * - VertexBuffer.UVKind
  16433. * - VertexBuffer.UV2Kind
  16434. * - VertexBuffer.UV3Kind
  16435. * - VertexBuffer.UV4Kind
  16436. * - VertexBuffer.UV5Kind
  16437. * - VertexBuffer.UV6Kind
  16438. * - VertexBuffer.ColorKind
  16439. * - VertexBuffer.MatricesIndicesKind
  16440. * - VertexBuffer.MatricesIndicesExtraKind
  16441. * - VertexBuffer.MatricesWeightsKind
  16442. * - VertexBuffer.MatricesWeightsExtraKind
  16443. *
  16444. * Returns the Mesh.
  16445. */
  16446. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16447. /**
  16448. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16449. * If the mesh has no geometry, it is simply returned as it is.
  16450. * The `data` are either a numeric array either a Float32Array.
  16451. * No new underlying VertexBuffer object is created.
  16452. * 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.
  16453. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16454. *
  16455. * Possible `kind` values :
  16456. * - VertexBuffer.PositionKind
  16457. * - VertexBuffer.UVKind
  16458. * - VertexBuffer.UV2Kind
  16459. * - VertexBuffer.UV3Kind
  16460. * - VertexBuffer.UV4Kind
  16461. * - VertexBuffer.UV5Kind
  16462. * - VertexBuffer.UV6Kind
  16463. * - VertexBuffer.ColorKind
  16464. * - VertexBuffer.MatricesIndicesKind
  16465. * - VertexBuffer.MatricesIndicesExtraKind
  16466. * - VertexBuffer.MatricesWeightsKind
  16467. * - VertexBuffer.MatricesWeightsExtraKind
  16468. *
  16469. * Returns the Mesh.
  16470. */
  16471. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16472. /**
  16473. * Sets the mesh indices.
  16474. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16475. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16476. * This method creates a new index buffer each call.
  16477. * Returns the Mesh.
  16478. */
  16479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16480. /**
  16481. * Boolean : True if the mesh owns the requested kind of data.
  16482. */
  16483. isVerticesDataPresent(kind: string): boolean;
  16484. /**
  16485. * Returns an array of indices (IndicesArray).
  16486. */
  16487. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16488. /**
  16489. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16490. * This means the mesh underlying bounding box and sphere are recomputed.
  16491. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16492. * @returns the current mesh
  16493. */
  16494. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16495. /** @hidden */ private _preActivate(): InstancedMesh;
  16496. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  16497. /** @hidden */ private _postActivate(): void;
  16498. getWorldMatrix(): Matrix;
  16499. readonly isAnInstance: boolean;
  16500. /**
  16501. * Returns the current associated LOD AbstractMesh.
  16502. */
  16503. getLOD(camera: Camera): AbstractMesh;
  16504. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  16505. /** @hidden */ private _generatePointsArray(): boolean;
  16506. /**
  16507. * Creates a new InstancedMesh from the current mesh.
  16508. * - name (string) : the cloned mesh name
  16509. * - newParent (optional Node) : the optional Node to parent the clone to.
  16510. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16511. *
  16512. * Returns the clone.
  16513. */
  16514. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16515. /**
  16516. * Disposes the InstancedMesh.
  16517. * Returns nothing.
  16518. */
  16519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16520. }
  16521. }
  16522. declare module BABYLON {
  16523. /**
  16524. * Defines the options associated with the creation of a shader material.
  16525. */
  16526. export interface IShaderMaterialOptions {
  16527. /**
  16528. * Does the material work in alpha blend mode
  16529. */
  16530. needAlphaBlending: boolean;
  16531. /**
  16532. * Does the material work in alpha test mode
  16533. */
  16534. needAlphaTesting: boolean;
  16535. /**
  16536. * The list of attribute names used in the shader
  16537. */
  16538. attributes: string[];
  16539. /**
  16540. * The list of unifrom names used in the shader
  16541. */
  16542. uniforms: string[];
  16543. /**
  16544. * The list of UBO names used in the shader
  16545. */
  16546. uniformBuffers: string[];
  16547. /**
  16548. * The list of sampler names used in the shader
  16549. */
  16550. samplers: string[];
  16551. /**
  16552. * The list of defines used in the shader
  16553. */
  16554. defines: string[];
  16555. }
  16556. /**
  16557. * 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.
  16558. *
  16559. * This returned material effects how the mesh will look based on the code in the shaders.
  16560. *
  16561. * @see http://doc.babylonjs.com/how_to/shader_material
  16562. */
  16563. export class ShaderMaterial extends Material {
  16564. private _shaderPath;
  16565. private _options;
  16566. private _textures;
  16567. private _textureArrays;
  16568. private _floats;
  16569. private _ints;
  16570. private _floatsArrays;
  16571. private _colors3;
  16572. private _colors3Arrays;
  16573. private _colors4;
  16574. private _vectors2;
  16575. private _vectors3;
  16576. private _vectors4;
  16577. private _matrices;
  16578. private _matrices3x3;
  16579. private _matrices2x2;
  16580. private _vectors2Arrays;
  16581. private _vectors3Arrays;
  16582. private _cachedWorldViewMatrix;
  16583. private _cachedWorldViewProjectionMatrix;
  16584. private _renderId;
  16585. /**
  16586. * Instantiate a new shader material.
  16587. * 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.
  16588. * This returned material effects how the mesh will look based on the code in the shaders.
  16589. * @see http://doc.babylonjs.com/how_to/shader_material
  16590. * @param name Define the name of the material in the scene
  16591. * @param scene Define the scene the material belongs to
  16592. * @param shaderPath Defines the route to the shader code in one of three ways:
  16593. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16594. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16595. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16596. * @param options Define the options used to create the shader
  16597. */
  16598. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16599. /**
  16600. * Gets the options used to compile the shader.
  16601. * They can be modified to trigger a new compilation
  16602. */
  16603. readonly options: IShaderMaterialOptions;
  16604. /**
  16605. * Gets the current class name of the material e.g. "ShaderMaterial"
  16606. * Mainly use in serialization.
  16607. * @returns the class name
  16608. */
  16609. getClassName(): string;
  16610. /**
  16611. * Specifies if the material will require alpha blending
  16612. * @returns a boolean specifying if alpha blending is needed
  16613. */
  16614. needAlphaBlending(): boolean;
  16615. /**
  16616. * Specifies if this material should be rendered in alpha test mode
  16617. * @returns a boolean specifying if an alpha test is needed.
  16618. */
  16619. needAlphaTesting(): boolean;
  16620. private _checkUniform;
  16621. /**
  16622. * Set a texture in the shader.
  16623. * @param name Define the name of the uniform samplers as defined in the shader
  16624. * @param texture Define the texture to bind to this sampler
  16625. * @return the material itself allowing "fluent" like uniform updates
  16626. */
  16627. setTexture(name: string, texture: Texture): ShaderMaterial;
  16628. /**
  16629. * Set a texture array in the shader.
  16630. * @param name Define the name of the uniform sampler array as defined in the shader
  16631. * @param textures Define the list of textures to bind to this sampler
  16632. * @return the material itself allowing "fluent" like uniform updates
  16633. */
  16634. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16635. /**
  16636. * Set a float in the shader.
  16637. * @param name Define the name of the uniform as defined in the shader
  16638. * @param value Define the value to give to the uniform
  16639. * @return the material itself allowing "fluent" like uniform updates
  16640. */
  16641. setFloat(name: string, value: number): ShaderMaterial;
  16642. /**
  16643. * Set a int in the shader.
  16644. * @param name Define the name of the uniform as defined in the shader
  16645. * @param value Define the value to give to the uniform
  16646. * @return the material itself allowing "fluent" like uniform updates
  16647. */
  16648. setInt(name: string, value: number): ShaderMaterial;
  16649. /**
  16650. * Set an array of floats in the shader.
  16651. * @param name Define the name of the uniform as defined in the shader
  16652. * @param value Define the value to give to the uniform
  16653. * @return the material itself allowing "fluent" like uniform updates
  16654. */
  16655. setFloats(name: string, value: number[]): ShaderMaterial;
  16656. /**
  16657. * Set a vec3 in the shader from a Color3.
  16658. * @param name Define the name of the uniform as defined in the shader
  16659. * @param value Define the value to give to the uniform
  16660. * @return the material itself allowing "fluent" like uniform updates
  16661. */
  16662. setColor3(name: string, value: Color3): ShaderMaterial;
  16663. /**
  16664. * Set a vec3 array in the shader from a Color3 array.
  16665. * @param name Define the name of the uniform as defined in the shader
  16666. * @param value Define the value to give to the uniform
  16667. * @return the material itself allowing "fluent" like uniform updates
  16668. */
  16669. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16670. /**
  16671. * Set a vec4 in the shader from a Color4.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setColor4(name: string, value: Color4): ShaderMaterial;
  16677. /**
  16678. * Set a vec2 in the shader from a Vector2.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setVector2(name: string, value: Vector2): ShaderMaterial;
  16684. /**
  16685. * Set a vec3 in the shader from a Vector3.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setVector3(name: string, value: Vector3): ShaderMaterial;
  16691. /**
  16692. * Set a vec4 in the shader from a Vector4.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setVector4(name: string, value: Vector4): ShaderMaterial;
  16698. /**
  16699. * Set a mat4 in the shader from a Matrix.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the material itself allowing "fluent" like uniform updates
  16703. */
  16704. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16705. /**
  16706. * Set a mat3 in the shader from a Float32Array.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16712. /**
  16713. * Set a mat2 in the shader from a Float32Array.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16719. /**
  16720. * Set a vec2 array in the shader from a number array.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setArray2(name: string, value: number[]): ShaderMaterial;
  16726. /**
  16727. * Set a vec3 array in the shader from a number array.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setArray3(name: string, value: number[]): ShaderMaterial;
  16733. private _checkCache;
  16734. /**
  16735. * Specifies that the submesh is ready to be used
  16736. * @param mesh defines the mesh to check
  16737. * @param subMesh defines which submesh to check
  16738. * @param useInstances specifies that instances should be used
  16739. * @returns a boolean indicating that the submesh is ready or not
  16740. */
  16741. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16742. /**
  16743. * Checks if the material is ready to render the requested mesh
  16744. * @param mesh Define the mesh to render
  16745. * @param useInstances Define whether or not the material is used with instances
  16746. * @returns true if ready, otherwise false
  16747. */
  16748. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16749. /**
  16750. * Binds the world matrix to the material
  16751. * @param world defines the world transformation matrix
  16752. */
  16753. bindOnlyWorldMatrix(world: Matrix): void;
  16754. /**
  16755. * Binds the material to the mesh
  16756. * @param world defines the world transformation matrix
  16757. * @param mesh defines the mesh to bind the material to
  16758. */
  16759. bind(world: Matrix, mesh?: Mesh): void;
  16760. /**
  16761. * Gets the active textures from the material
  16762. * @returns an array of textures
  16763. */
  16764. getActiveTextures(): BaseTexture[];
  16765. /**
  16766. * Specifies if the material uses a texture
  16767. * @param texture defines the texture to check against the material
  16768. * @returns a boolean specifying if the material uses the texture
  16769. */
  16770. hasTexture(texture: BaseTexture): boolean;
  16771. /**
  16772. * Makes a duplicate of the material, and gives it a new name
  16773. * @param name defines the new name for the duplicated material
  16774. * @returns the cloned material
  16775. */
  16776. clone(name: string): ShaderMaterial;
  16777. /**
  16778. * Disposes the material
  16779. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16780. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16781. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16782. */
  16783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16784. /**
  16785. * Serializes this material in a JSON representation
  16786. * @returns the serialized material object
  16787. */
  16788. serialize(): any;
  16789. /**
  16790. * Creates a shader material from parsed shader material data
  16791. * @param source defines the JSON represnetation of the material
  16792. * @param scene defines the hosting scene
  16793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16794. * @returns a new material
  16795. */
  16796. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16797. }
  16798. }
  16799. declare module BABYLON {
  16800. /** @hidden */
  16801. export var colorPixelShader: {
  16802. name: string;
  16803. shader: string;
  16804. };
  16805. }
  16806. declare module BABYLON {
  16807. /** @hidden */
  16808. export var colorVertexShader: {
  16809. name: string;
  16810. shader: string;
  16811. };
  16812. }
  16813. declare module BABYLON {
  16814. /**
  16815. * Line mesh
  16816. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16817. */
  16818. export class LinesMesh extends Mesh {
  16819. /**
  16820. * If vertex color should be applied to the mesh
  16821. */
  16822. readonly useVertexColor?: boolean | undefined;
  16823. /**
  16824. * If vertex alpha should be applied to the mesh
  16825. */
  16826. readonly useVertexAlpha?: boolean | undefined;
  16827. /**
  16828. * Color of the line (Default: White)
  16829. */
  16830. color: Color3;
  16831. /**
  16832. * Alpha of the line (Default: 1)
  16833. */
  16834. alpha: number;
  16835. /**
  16836. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16837. * This margin is expressed in world space coordinates, so its value may vary.
  16838. * Default value is 0.1
  16839. */
  16840. intersectionThreshold: number;
  16841. private _colorShader;
  16842. private color4;
  16843. /**
  16844. * Creates a new LinesMesh
  16845. * @param name defines the name
  16846. * @param scene defines the hosting scene
  16847. * @param parent defines the parent mesh if any
  16848. * @param source defines the optional source LinesMesh used to clone data from
  16849. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16850. * When false, achieved by calling a clone(), also passing False.
  16851. * This will make creation of children, recursive.
  16852. * @param useVertexColor defines if this LinesMesh supports vertex color
  16853. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16854. */
  16855. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16856. /**
  16857. * If vertex color should be applied to the mesh
  16858. */
  16859. useVertexColor?: boolean | undefined,
  16860. /**
  16861. * If vertex alpha should be applied to the mesh
  16862. */
  16863. useVertexAlpha?: boolean | undefined);
  16864. private _addClipPlaneDefine;
  16865. private _removeClipPlaneDefine;
  16866. isReady(): boolean;
  16867. /**
  16868. * Returns the string "LineMesh"
  16869. */
  16870. getClassName(): string;
  16871. /**
  16872. * @hidden
  16873. */
  16874. /**
  16875. * @hidden
  16876. */
  16877. material: Material;
  16878. /**
  16879. * @hidden
  16880. */
  16881. readonly checkCollisions: boolean;
  16882. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16883. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16884. /**
  16885. * Disposes of the line mesh
  16886. * @param doNotRecurse If children should be disposed
  16887. */
  16888. dispose(doNotRecurse?: boolean): void;
  16889. /**
  16890. * Returns a new LineMesh object cloned from the current one.
  16891. */
  16892. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16893. /**
  16894. * Creates a new InstancedLinesMesh object from the mesh model.
  16895. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16896. * @param name defines the name of the new instance
  16897. * @returns a new InstancedLinesMesh
  16898. */
  16899. createInstance(name: string): InstancedLinesMesh;
  16900. }
  16901. /**
  16902. * Creates an instance based on a source LinesMesh
  16903. */
  16904. export class InstancedLinesMesh extends InstancedMesh {
  16905. /**
  16906. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16907. * This margin is expressed in world space coordinates, so its value may vary.
  16908. * Initilized with the intersectionThreshold value of the source LinesMesh
  16909. */
  16910. intersectionThreshold: number;
  16911. constructor(name: string, source: LinesMesh);
  16912. /**
  16913. * Returns the string "InstancedLinesMesh".
  16914. */
  16915. getClassName(): string;
  16916. }
  16917. }
  16918. declare module BABYLON {
  16919. /** @hidden */
  16920. export var linePixelShader: {
  16921. name: string;
  16922. shader: string;
  16923. };
  16924. }
  16925. declare module BABYLON {
  16926. /** @hidden */
  16927. export var lineVertexShader: {
  16928. name: string;
  16929. shader: string;
  16930. };
  16931. }
  16932. declare module BABYLON {
  16933. interface AbstractMesh {
  16934. /**
  16935. * Gets the edgesRenderer associated with the mesh
  16936. */
  16937. edgesRenderer: Nullable<EdgesRenderer>;
  16938. }
  16939. interface LinesMesh {
  16940. /**
  16941. * Enables the edge rendering mode on the mesh.
  16942. * This mode makes the mesh edges visible
  16943. * @param epsilon defines the maximal distance between two angles to detect a face
  16944. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16945. * @returns the currentAbstractMesh
  16946. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16947. */
  16948. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16949. }
  16950. interface InstancedLinesMesh {
  16951. /**
  16952. * Enables the edge rendering mode on the mesh.
  16953. * This mode makes the mesh edges visible
  16954. * @param epsilon defines the maximal distance between two angles to detect a face
  16955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16956. * @returns the current InstancedLinesMesh
  16957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16958. */
  16959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16960. }
  16961. /**
  16962. * Defines the minimum contract an Edges renderer should follow.
  16963. */
  16964. export interface IEdgesRenderer extends IDisposable {
  16965. /**
  16966. * Gets or sets a boolean indicating if the edgesRenderer is active
  16967. */
  16968. isEnabled: boolean;
  16969. /**
  16970. * Renders the edges of the attached mesh,
  16971. */
  16972. render(): void;
  16973. /**
  16974. * Checks wether or not the edges renderer is ready to render.
  16975. * @return true if ready, otherwise false.
  16976. */
  16977. isReady(): boolean;
  16978. }
  16979. /**
  16980. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16981. */
  16982. export class EdgesRenderer implements IEdgesRenderer {
  16983. /**
  16984. * Define the size of the edges with an orthographic camera
  16985. */
  16986. edgesWidthScalerForOrthographic: number;
  16987. /**
  16988. * Define the size of the edges with a perspective camera
  16989. */
  16990. edgesWidthScalerForPerspective: number;
  16991. protected _source: AbstractMesh;
  16992. protected _linesPositions: number[];
  16993. protected _linesNormals: number[];
  16994. protected _linesIndices: number[];
  16995. protected _epsilon: number;
  16996. protected _indicesCount: number;
  16997. protected _lineShader: ShaderMaterial;
  16998. protected _ib: DataBuffer;
  16999. protected _buffers: {
  17000. [key: string]: Nullable<VertexBuffer>;
  17001. };
  17002. protected _checkVerticesInsteadOfIndices: boolean;
  17003. private _meshRebuildObserver;
  17004. private _meshDisposeObserver;
  17005. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17006. isEnabled: boolean;
  17007. /**
  17008. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17009. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17010. * @param source Mesh used to create edges
  17011. * @param epsilon sum of angles in adjacency to check for edge
  17012. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17013. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17014. */
  17015. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17016. protected _prepareRessources(): void;
  17017. /** @hidden */ private _rebuild(): void;
  17018. /**
  17019. * Releases the required resources for the edges renderer
  17020. */
  17021. dispose(): void;
  17022. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17023. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17024. /**
  17025. * Checks if the pair of p0 and p1 is en edge
  17026. * @param faceIndex
  17027. * @param edge
  17028. * @param faceNormals
  17029. * @param p0
  17030. * @param p1
  17031. * @private
  17032. */
  17033. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17034. /**
  17035. * push line into the position, normal and index buffer
  17036. * @protected
  17037. */
  17038. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17039. /**
  17040. * Generates lines edges from adjacencjes
  17041. * @private
  17042. */ private _generateEdgesLines(): void;
  17043. /**
  17044. * Checks wether or not the edges renderer is ready to render.
  17045. * @return true if ready, otherwise false.
  17046. */
  17047. isReady(): boolean;
  17048. /**
  17049. * Renders the edges of the attached mesh,
  17050. */
  17051. render(): void;
  17052. }
  17053. /**
  17054. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17055. */
  17056. export class LineEdgesRenderer extends EdgesRenderer {
  17057. /**
  17058. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17059. * @param source LineMesh used to generate edges
  17060. * @param epsilon not important (specified angle for edge detection)
  17061. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17062. */
  17063. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17064. /**
  17065. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17066. */ private _generateEdgesLines(): void;
  17067. }
  17068. }
  17069. declare module BABYLON {
  17070. /**
  17071. * This represents the object necessary to create a rendering group.
  17072. * This is exclusively used and created by the rendering manager.
  17073. * To modify the behavior, you use the available helpers in your scene or meshes.
  17074. * @hidden
  17075. */
  17076. export class RenderingGroup {
  17077. index: number;
  17078. private static _zeroVector;
  17079. private _scene;
  17080. private _opaqueSubMeshes;
  17081. private _transparentSubMeshes;
  17082. private _alphaTestSubMeshes;
  17083. private _depthOnlySubMeshes;
  17084. private _particleSystems;
  17085. private _spriteManagers;
  17086. private _opaqueSortCompareFn;
  17087. private _alphaTestSortCompareFn;
  17088. private _transparentSortCompareFn;
  17089. private _renderOpaque;
  17090. private _renderAlphaTest;
  17091. private _renderTransparent;
  17092. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  17093. onBeforeTransparentRendering: () => void;
  17094. /**
  17095. * Set the opaque sort comparison function.
  17096. * If null the sub meshes will be render in the order they were created
  17097. */
  17098. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17099. /**
  17100. * Set the alpha test sort comparison function.
  17101. * If null the sub meshes will be render in the order they were created
  17102. */
  17103. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17104. /**
  17105. * Set the transparent sort comparison function.
  17106. * If null the sub meshes will be render in the order they were created
  17107. */
  17108. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17109. /**
  17110. * Creates a new rendering group.
  17111. * @param index The rendering group index
  17112. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17113. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17114. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17115. */
  17116. 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>);
  17117. /**
  17118. * Render all the sub meshes contained in the group.
  17119. * @param customRenderFunction Used to override the default render behaviour of the group.
  17120. * @returns true if rendered some submeshes.
  17121. */
  17122. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17123. /**
  17124. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17125. * @param subMeshes The submeshes to render
  17126. */
  17127. private renderOpaqueSorted;
  17128. /**
  17129. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17130. * @param subMeshes The submeshes to render
  17131. */
  17132. private renderAlphaTestSorted;
  17133. /**
  17134. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17135. * @param subMeshes The submeshes to render
  17136. */
  17137. private renderTransparentSorted;
  17138. /**
  17139. * Renders the submeshes in a specified order.
  17140. * @param subMeshes The submeshes to sort before render
  17141. * @param sortCompareFn The comparison function use to sort
  17142. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17143. * @param transparent Specifies to activate blending if true
  17144. */
  17145. private static renderSorted;
  17146. /**
  17147. * Renders the submeshes in the order they were dispatched (no sort applied).
  17148. * @param subMeshes The submeshes to render
  17149. */
  17150. private static renderUnsorted;
  17151. /**
  17152. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17153. * are rendered back to front if in the same alpha index.
  17154. *
  17155. * @param a The first submesh
  17156. * @param b The second submesh
  17157. * @returns The result of the comparison
  17158. */
  17159. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17160. /**
  17161. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17162. * are rendered back to front.
  17163. *
  17164. * @param a The first submesh
  17165. * @param b The second submesh
  17166. * @returns The result of the comparison
  17167. */
  17168. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17169. /**
  17170. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17171. * are rendered front to back (prevent overdraw).
  17172. *
  17173. * @param a The first submesh
  17174. * @param b The second submesh
  17175. * @returns The result of the comparison
  17176. */
  17177. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17178. /**
  17179. * Resets the different lists of submeshes to prepare a new frame.
  17180. */
  17181. prepare(): void;
  17182. dispose(): void;
  17183. /**
  17184. * Inserts the submesh in its correct queue depending on its material.
  17185. * @param subMesh The submesh to dispatch
  17186. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17187. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17188. */
  17189. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17190. dispatchSprites(spriteManager: ISpriteManager): void;
  17191. dispatchParticles(particleSystem: IParticleSystem): void;
  17192. private _renderParticles;
  17193. private _renderSprites;
  17194. }
  17195. }
  17196. declare module BABYLON {
  17197. /**
  17198. * Interface describing the different options available in the rendering manager
  17199. * regarding Auto Clear between groups.
  17200. */
  17201. export interface IRenderingManagerAutoClearSetup {
  17202. /**
  17203. * Defines whether or not autoclear is enable.
  17204. */
  17205. autoClear: boolean;
  17206. /**
  17207. * Defines whether or not to autoclear the depth buffer.
  17208. */
  17209. depth: boolean;
  17210. /**
  17211. * Defines whether or not to autoclear the stencil buffer.
  17212. */
  17213. stencil: boolean;
  17214. }
  17215. /**
  17216. * This class is used by the onRenderingGroupObservable
  17217. */
  17218. export class RenderingGroupInfo {
  17219. /**
  17220. * The Scene that being rendered
  17221. */
  17222. scene: Scene;
  17223. /**
  17224. * The camera currently used for the rendering pass
  17225. */
  17226. camera: Nullable<Camera>;
  17227. /**
  17228. * The ID of the renderingGroup being processed
  17229. */
  17230. renderingGroupId: number;
  17231. }
  17232. /**
  17233. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17234. * It is enable to manage the different groups as well as the different necessary sort functions.
  17235. * This should not be used directly aside of the few static configurations
  17236. */
  17237. export class RenderingManager {
  17238. /**
  17239. * The max id used for rendering groups (not included)
  17240. */
  17241. static MAX_RENDERINGGROUPS: number;
  17242. /**
  17243. * The min id used for rendering groups (included)
  17244. */
  17245. static MIN_RENDERINGGROUPS: number;
  17246. /**
  17247. * Used to globally prevent autoclearing scenes.
  17248. */
  17249. static AUTOCLEAR: boolean;
  17250. /**
  17251. * @hidden
  17252. */ private _useSceneAutoClearSetup: boolean;
  17253. private _scene;
  17254. private _renderingGroups;
  17255. private _depthStencilBufferAlreadyCleaned;
  17256. private _autoClearDepthStencil;
  17257. private _customOpaqueSortCompareFn;
  17258. private _customAlphaTestSortCompareFn;
  17259. private _customTransparentSortCompareFn;
  17260. private _renderingGroupInfo;
  17261. /**
  17262. * Instantiates a new rendering group for a particular scene
  17263. * @param scene Defines the scene the groups belongs to
  17264. */
  17265. constructor(scene: Scene);
  17266. private _clearDepthStencilBuffer;
  17267. /**
  17268. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17269. * @hidden
  17270. */
  17271. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17272. /**
  17273. * Resets the different information of the group to prepare a new frame
  17274. * @hidden
  17275. */
  17276. reset(): void;
  17277. /**
  17278. * Dispose and release the group and its associated resources.
  17279. * @hidden
  17280. */
  17281. dispose(): void;
  17282. /**
  17283. * Clear the info related to rendering groups preventing retention points during dispose.
  17284. */
  17285. freeRenderingGroups(): void;
  17286. private _prepareRenderingGroup;
  17287. /**
  17288. * Add a sprite manager to the rendering manager in order to render it this frame.
  17289. * @param spriteManager Define the sprite manager to render
  17290. */
  17291. dispatchSprites(spriteManager: ISpriteManager): void;
  17292. /**
  17293. * Add a particle system to the rendering manager in order to render it this frame.
  17294. * @param particleSystem Define the particle system to render
  17295. */
  17296. dispatchParticles(particleSystem: IParticleSystem): void;
  17297. /**
  17298. * Add a submesh to the manager in order to render it this frame
  17299. * @param subMesh The submesh to dispatch
  17300. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17301. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17302. */
  17303. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17304. /**
  17305. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17306. * This allowed control for front to back rendering or reversly depending of the special needs.
  17307. *
  17308. * @param renderingGroupId The rendering group id corresponding to its index
  17309. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17310. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17311. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17312. */
  17313. 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;
  17314. /**
  17315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17316. *
  17317. * @param renderingGroupId The rendering group id corresponding to its index
  17318. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17319. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17320. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17321. */
  17322. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17323. /**
  17324. * Gets the current auto clear configuration for one rendering group of the rendering
  17325. * manager.
  17326. * @param index the rendering group index to get the information for
  17327. * @returns The auto clear setup for the requested rendering group
  17328. */
  17329. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17330. }
  17331. }
  17332. declare module BABYLON {
  17333. /**
  17334. * This Helps creating a texture that will be created from a camera in your scene.
  17335. * It is basically a dynamic texture that could be used to create special effects for instance.
  17336. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17337. */
  17338. export class RenderTargetTexture extends Texture {
  17339. isCube: boolean;
  17340. /**
  17341. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17342. */
  17343. static readonly REFRESHRATE_RENDER_ONCE: number;
  17344. /**
  17345. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17346. */
  17347. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17348. /**
  17349. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17350. * the central point of your effect and can save a lot of performances.
  17351. */
  17352. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17353. /**
  17354. * Use this predicate to dynamically define the list of mesh you want to render.
  17355. * If set, the renderList property will be overwritten.
  17356. */
  17357. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17358. private _renderList;
  17359. /**
  17360. * Use this list to define the list of mesh you want to render.
  17361. */
  17362. renderList: Nullable<Array<AbstractMesh>>;
  17363. private _hookArray;
  17364. /**
  17365. * Define if particles should be rendered in your texture.
  17366. */
  17367. renderParticles: boolean;
  17368. /**
  17369. * Define if sprites should be rendered in your texture.
  17370. */
  17371. renderSprites: boolean;
  17372. /**
  17373. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17374. */
  17375. coordinatesMode: number;
  17376. /**
  17377. * Define the camera used to render the texture.
  17378. */
  17379. activeCamera: Nullable<Camera>;
  17380. /**
  17381. * Override the render function of the texture with your own one.
  17382. */
  17383. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17384. /**
  17385. * Define if camera post processes should be use while rendering the texture.
  17386. */
  17387. useCameraPostProcesses: boolean;
  17388. /**
  17389. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17390. */
  17391. ignoreCameraViewport: boolean;
  17392. private _postProcessManager;
  17393. private _postProcesses;
  17394. private _resizeObserver;
  17395. /**
  17396. * An event triggered when the texture is unbind.
  17397. */
  17398. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17399. /**
  17400. * An event triggered when the texture is unbind.
  17401. */
  17402. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17403. private _onAfterUnbindObserver;
  17404. /**
  17405. * Set a after unbind callback in the texture.
  17406. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17407. */
  17408. onAfterUnbind: () => void;
  17409. /**
  17410. * An event triggered before rendering the texture
  17411. */
  17412. onBeforeRenderObservable: Observable<number>;
  17413. private _onBeforeRenderObserver;
  17414. /**
  17415. * Set a before render callback in the texture.
  17416. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17417. */
  17418. onBeforeRender: (faceIndex: number) => void;
  17419. /**
  17420. * An event triggered after rendering the texture
  17421. */
  17422. onAfterRenderObservable: Observable<number>;
  17423. private _onAfterRenderObserver;
  17424. /**
  17425. * Set a after render callback in the texture.
  17426. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17427. */
  17428. onAfterRender: (faceIndex: number) => void;
  17429. /**
  17430. * An event triggered after the texture clear
  17431. */
  17432. onClearObservable: Observable<Engine>;
  17433. private _onClearObserver;
  17434. /**
  17435. * Set a clear callback in the texture.
  17436. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17437. */
  17438. onClear: (Engine: Engine) => void;
  17439. /**
  17440. * Define the clear color of the Render Target if it should be different from the scene.
  17441. */
  17442. clearColor: Color4;
  17443. protected _size: number | {
  17444. width: number;
  17445. height: number;
  17446. };
  17447. protected _initialSizeParameter: number | {
  17448. width: number;
  17449. height: number;
  17450. } | {
  17451. ratio: number;
  17452. };
  17453. protected _sizeRatio: Nullable<number>;
  17454. /** @hidden */ private _generateMipMaps: boolean;
  17455. protected _renderingManager: RenderingManager;
  17456. /** @hidden */ private _waitingRenderList: string[];
  17457. protected _doNotChangeAspectRatio: boolean;
  17458. protected _currentRefreshId: number;
  17459. protected _refreshRate: number;
  17460. protected _textureMatrix: Matrix;
  17461. protected _samples: number;
  17462. protected _renderTargetOptions: RenderTargetCreationOptions;
  17463. /**
  17464. * Gets render target creation options that were used.
  17465. */
  17466. readonly renderTargetOptions: RenderTargetCreationOptions;
  17467. protected _engine: Engine;
  17468. protected _onRatioRescale(): void;
  17469. /**
  17470. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17471. * It must define where the camera used to render the texture is set
  17472. */
  17473. boundingBoxPosition: Vector3;
  17474. private _boundingBoxSize;
  17475. /**
  17476. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17477. * When defined, the cubemap will switch to local mode
  17478. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17479. * @example https://www.babylonjs-playground.com/#RNASML
  17480. */
  17481. boundingBoxSize: Vector3;
  17482. /**
  17483. * In case the RTT has been created with a depth texture, get the associated
  17484. * depth texture.
  17485. * Otherwise, return null.
  17486. */
  17487. depthStencilTexture: Nullable<InternalTexture>;
  17488. /**
  17489. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17490. * or used a shadow, depth texture...
  17491. * @param name The friendly name of the texture
  17492. * @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)
  17493. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17494. * @param generateMipMaps True if mip maps need to be generated after render.
  17495. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17496. * @param type The type of the buffer in the RTT (int, half float, float...)
  17497. * @param isCube True if a cube texture needs to be created
  17498. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17499. * @param generateDepthBuffer True to generate a depth buffer
  17500. * @param generateStencilBuffer True to generate a stencil buffer
  17501. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17502. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17504. */
  17505. constructor(name: string, size: number | {
  17506. width: number;
  17507. height: number;
  17508. } | {
  17509. ratio: number;
  17510. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17511. /**
  17512. * Creates a depth stencil texture.
  17513. * This is only available in WebGL 2 or with the depth texture extension available.
  17514. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17515. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17516. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17517. */
  17518. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17519. private _processSizeParameter;
  17520. /**
  17521. * Define the number of samples to use in case of MSAA.
  17522. * It defaults to one meaning no MSAA has been enabled.
  17523. */
  17524. samples: number;
  17525. /**
  17526. * Resets the refresh counter of the texture and start bak from scratch.
  17527. * Could be useful to regenerate the texture if it is setup to render only once.
  17528. */
  17529. resetRefreshCounter(): void;
  17530. /**
  17531. * Define the refresh rate of the texture or the rendering frequency.
  17532. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17533. */
  17534. refreshRate: number;
  17535. /**
  17536. * Adds a post process to the render target rendering passes.
  17537. * @param postProcess define the post process to add
  17538. */
  17539. addPostProcess(postProcess: PostProcess): void;
  17540. /**
  17541. * Clear all the post processes attached to the render target
  17542. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17543. */
  17544. clearPostProcesses(dispose?: boolean): void;
  17545. /**
  17546. * Remove one of the post process from the list of attached post processes to the texture
  17547. * @param postProcess define the post process to remove from the list
  17548. */
  17549. removePostProcess(postProcess: PostProcess): void;
  17550. /** @hidden */ private _shouldRender(): boolean;
  17551. /**
  17552. * Gets the actual render size of the texture.
  17553. * @returns the width of the render size
  17554. */
  17555. getRenderSize(): number;
  17556. /**
  17557. * Gets the actual render width of the texture.
  17558. * @returns the width of the render size
  17559. */
  17560. getRenderWidth(): number;
  17561. /**
  17562. * Gets the actual render height of the texture.
  17563. * @returns the height of the render size
  17564. */
  17565. getRenderHeight(): number;
  17566. /**
  17567. * Get if the texture can be rescaled or not.
  17568. */
  17569. readonly canRescale: boolean;
  17570. /**
  17571. * Resize the texture using a ratio.
  17572. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17573. */
  17574. scale(ratio: number): void;
  17575. /**
  17576. * Get the texture reflection matrix used to rotate/transform the reflection.
  17577. * @returns the reflection matrix
  17578. */
  17579. getReflectionTextureMatrix(): Matrix;
  17580. /**
  17581. * Resize the texture to a new desired size.
  17582. * Be carrefull as it will recreate all the data in the new texture.
  17583. * @param size Define the new size. It can be:
  17584. * - a number for squared texture,
  17585. * - an object containing { width: number, height: number }
  17586. * - or an object containing a ratio { ratio: number }
  17587. */
  17588. resize(size: number | {
  17589. width: number;
  17590. height: number;
  17591. } | {
  17592. ratio: number;
  17593. }): void;
  17594. /**
  17595. * Renders all the objects from the render list into the texture.
  17596. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17597. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17598. */
  17599. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17600. private _bestReflectionRenderTargetDimension;
  17601. /**
  17602. * @hidden
  17603. * @param faceIndex face index to bind to if this is a cubetexture
  17604. */ private _bindFrameBuffer(faceIndex?: number): void;
  17605. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17606. private renderToTarget;
  17607. /**
  17608. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17609. * This allowed control for front to back rendering or reversly depending of the special needs.
  17610. *
  17611. * @param renderingGroupId The rendering group id corresponding to its index
  17612. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17613. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17614. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17615. */
  17616. 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;
  17617. /**
  17618. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17619. *
  17620. * @param renderingGroupId The rendering group id corresponding to its index
  17621. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17622. */
  17623. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17624. /**
  17625. * Clones the texture.
  17626. * @returns the cloned texture
  17627. */
  17628. clone(): RenderTargetTexture;
  17629. /**
  17630. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17631. * @returns The JSON representation of the texture
  17632. */
  17633. serialize(): any;
  17634. /**
  17635. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17636. */
  17637. disposeFramebufferObjects(): void;
  17638. /**
  17639. * Dispose the texture and release its associated resources.
  17640. */
  17641. dispose(): void;
  17642. /** @hidden */ private _rebuild(): void;
  17643. /**
  17644. * Clear the info related to rendering groups preventing retention point in material dispose.
  17645. */
  17646. freeRenderingGroups(): void;
  17647. /**
  17648. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17649. * @returns the view count
  17650. */
  17651. getViewCount(): number;
  17652. }
  17653. }
  17654. declare module BABYLON {
  17655. /**
  17656. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17657. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17658. * You can then easily use it as a reflectionTexture on a flat surface.
  17659. * In case the surface is not a plane, please consider relying on reflection probes.
  17660. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17661. */
  17662. export class MirrorTexture extends RenderTargetTexture {
  17663. private scene;
  17664. /**
  17665. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17666. * 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.
  17667. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17668. */
  17669. mirrorPlane: Plane;
  17670. /**
  17671. * Define the blur ratio used to blur the reflection if needed.
  17672. */
  17673. blurRatio: number;
  17674. /**
  17675. * Define the adaptive blur kernel used to blur the reflection if needed.
  17676. * This will autocompute the closest best match for the `blurKernel`
  17677. */
  17678. adaptiveBlurKernel: number;
  17679. /**
  17680. * Define the blur kernel used to blur the reflection if needed.
  17681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17682. */
  17683. blurKernel: number;
  17684. /**
  17685. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17686. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17687. */
  17688. blurKernelX: number;
  17689. /**
  17690. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17691. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17692. */
  17693. blurKernelY: number;
  17694. private _autoComputeBlurKernel;
  17695. protected _onRatioRescale(): void;
  17696. private _updateGammaSpace;
  17697. private _imageProcessingConfigChangeObserver;
  17698. private _transformMatrix;
  17699. private _mirrorMatrix;
  17700. private _savedViewMatrix;
  17701. private _blurX;
  17702. private _blurY;
  17703. private _adaptiveBlurKernel;
  17704. private _blurKernelX;
  17705. private _blurKernelY;
  17706. private _blurRatio;
  17707. /**
  17708. * Instantiates a Mirror Texture.
  17709. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17710. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17711. * You can then easily use it as a reflectionTexture on a flat surface.
  17712. * In case the surface is not a plane, please consider relying on reflection probes.
  17713. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17714. * @param name
  17715. * @param size
  17716. * @param scene
  17717. * @param generateMipMaps
  17718. * @param type
  17719. * @param samplingMode
  17720. * @param generateDepthBuffer
  17721. */
  17722. constructor(name: string, size: number | {
  17723. width: number;
  17724. height: number;
  17725. } | {
  17726. ratio: number;
  17727. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17728. private _preparePostProcesses;
  17729. /**
  17730. * Clone the mirror texture.
  17731. * @returns the cloned texture
  17732. */
  17733. clone(): MirrorTexture;
  17734. /**
  17735. * Serialize the texture to a JSON representation you could use in Parse later on
  17736. * @returns the serialized JSON representation
  17737. */
  17738. serialize(): any;
  17739. /**
  17740. * Dispose the texture and release its associated resources.
  17741. */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module BABYLON {
  17746. /**
  17747. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17748. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17749. */
  17750. export class Texture extends BaseTexture {
  17751. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17752. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17753. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17754. /** nearest is mag = nearest and min = nearest and mip = linear */
  17755. static readonly NEAREST_SAMPLINGMODE: number;
  17756. /** nearest is mag = nearest and min = nearest and mip = linear */
  17757. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17758. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17759. static readonly BILINEAR_SAMPLINGMODE: number;
  17760. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17761. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17762. /** Trilinear is mag = linear and min = linear and mip = linear */
  17763. static readonly TRILINEAR_SAMPLINGMODE: number;
  17764. /** Trilinear is mag = linear and min = linear and mip = linear */
  17765. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17766. /** mag = nearest and min = nearest and mip = nearest */
  17767. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17768. /** mag = nearest and min = linear and mip = nearest */
  17769. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17770. /** mag = nearest and min = linear and mip = linear */
  17771. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17772. /** mag = nearest and min = linear and mip = none */
  17773. static readonly NEAREST_LINEAR: number;
  17774. /** mag = nearest and min = nearest and mip = none */
  17775. static readonly NEAREST_NEAREST: number;
  17776. /** mag = linear and min = nearest and mip = nearest */
  17777. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17778. /** mag = linear and min = nearest and mip = linear */
  17779. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17780. /** mag = linear and min = linear and mip = none */
  17781. static readonly LINEAR_LINEAR: number;
  17782. /** mag = linear and min = nearest and mip = none */
  17783. static readonly LINEAR_NEAREST: number;
  17784. /** Explicit coordinates mode */
  17785. static readonly EXPLICIT_MODE: number;
  17786. /** Spherical coordinates mode */
  17787. static readonly SPHERICAL_MODE: number;
  17788. /** Planar coordinates mode */
  17789. static readonly PLANAR_MODE: number;
  17790. /** Cubic coordinates mode */
  17791. static readonly CUBIC_MODE: number;
  17792. /** Projection coordinates mode */
  17793. static readonly PROJECTION_MODE: number;
  17794. /** Inverse Cubic coordinates mode */
  17795. static readonly SKYBOX_MODE: number;
  17796. /** Inverse Cubic coordinates mode */
  17797. static readonly INVCUBIC_MODE: number;
  17798. /** Equirectangular coordinates mode */
  17799. static readonly EQUIRECTANGULAR_MODE: number;
  17800. /** Equirectangular Fixed coordinates mode */
  17801. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17802. /** Equirectangular Fixed Mirrored coordinates mode */
  17803. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17804. /** Texture is not repeating outside of 0..1 UVs */
  17805. static readonly CLAMP_ADDRESSMODE: number;
  17806. /** Texture is repeating outside of 0..1 UVs */
  17807. static readonly WRAP_ADDRESSMODE: number;
  17808. /** Texture is repeating and mirrored */
  17809. static readonly MIRROR_ADDRESSMODE: number;
  17810. /**
  17811. * 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
  17812. */
  17813. static UseSerializedUrlIfAny: boolean;
  17814. /**
  17815. * Define the url of the texture.
  17816. */
  17817. url: Nullable<string>;
  17818. /**
  17819. * Define an offset on the texture to offset the u coordinates of the UVs
  17820. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17821. */
  17822. uOffset: number;
  17823. /**
  17824. * Define an offset on the texture to offset the v coordinates of the UVs
  17825. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17826. */
  17827. vOffset: number;
  17828. /**
  17829. * Define an offset on the texture to scale the u coordinates of the UVs
  17830. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17831. */
  17832. uScale: number;
  17833. /**
  17834. * Define an offset on the texture to scale the v coordinates of the UVs
  17835. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17836. */
  17837. vScale: number;
  17838. /**
  17839. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17840. * @see http://doc.babylonjs.com/how_to/more_materials
  17841. */
  17842. uAng: number;
  17843. /**
  17844. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17845. * @see http://doc.babylonjs.com/how_to/more_materials
  17846. */
  17847. vAng: number;
  17848. /**
  17849. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17850. * @see http://doc.babylonjs.com/how_to/more_materials
  17851. */
  17852. wAng: number;
  17853. /**
  17854. * Defines the center of rotation (U)
  17855. */
  17856. uRotationCenter: number;
  17857. /**
  17858. * Defines the center of rotation (V)
  17859. */
  17860. vRotationCenter: number;
  17861. /**
  17862. * Defines the center of rotation (W)
  17863. */
  17864. wRotationCenter: number;
  17865. /**
  17866. * Are mip maps generated for this texture or not.
  17867. */
  17868. readonly noMipmap: boolean;
  17869. /**
  17870. * List of inspectable custom properties (used by the Inspector)
  17871. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17872. */
  17873. inspectableCustomProperties: Nullable<IInspectable[]>;
  17874. private _noMipmap;
  17875. /** @hidden */ private _invertY: boolean;
  17876. private _rowGenerationMatrix;
  17877. private _cachedTextureMatrix;
  17878. private _projectionModeMatrix;
  17879. private _t0;
  17880. private _t1;
  17881. private _t2;
  17882. private _cachedUOffset;
  17883. private _cachedVOffset;
  17884. private _cachedUScale;
  17885. private _cachedVScale;
  17886. private _cachedUAng;
  17887. private _cachedVAng;
  17888. private _cachedWAng;
  17889. private _cachedProjectionMatrixId;
  17890. private _cachedCoordinatesMode;
  17891. /** @hidden */
  17892. protected _initialSamplingMode: number;
  17893. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17894. private _deleteBuffer;
  17895. protected _format: Nullable<number>;
  17896. private _delayedOnLoad;
  17897. private _delayedOnError;
  17898. /**
  17899. * Observable triggered once the texture has been loaded.
  17900. */
  17901. onLoadObservable: Observable<Texture>;
  17902. protected _isBlocking: boolean;
  17903. /**
  17904. * Is the texture preventing material to render while loading.
  17905. * If false, a default texture will be used instead of the loading one during the preparation step.
  17906. */
  17907. isBlocking: boolean;
  17908. /**
  17909. * Get the current sampling mode associated with the texture.
  17910. */
  17911. readonly samplingMode: number;
  17912. /**
  17913. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17914. */
  17915. readonly invertY: boolean;
  17916. /**
  17917. * Instantiates a new texture.
  17918. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17919. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17920. * @param url define the url of the picture to load as a texture
  17921. * @param scene define the scene the texture will belong to
  17922. * @param noMipmap define if the texture will require mip maps or not
  17923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17925. * @param onLoad define a callback triggered when the texture has been loaded
  17926. * @param onError define a callback triggered when an error occurred during the loading session
  17927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17928. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17929. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17930. */
  17931. 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);
  17932. /**
  17933. * Update the url (and optional buffer) of this texture if url was null during construction.
  17934. * @param url the url of the texture
  17935. * @param buffer the buffer of the texture (defaults to null)
  17936. * @param onLoad callback called when the texture is loaded (defaults to null)
  17937. */
  17938. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17939. /**
  17940. * Finish the loading sequence of a texture flagged as delayed load.
  17941. * @hidden
  17942. */
  17943. delayLoad(): void;
  17944. private _prepareRowForTextureGeneration;
  17945. /**
  17946. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17947. * @returns the transform matrix of the texture.
  17948. */
  17949. getTextureMatrix(): Matrix;
  17950. /**
  17951. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17952. * @returns The reflection texture transform
  17953. */
  17954. getReflectionTextureMatrix(): Matrix;
  17955. /**
  17956. * Clones the texture.
  17957. * @returns the cloned texture
  17958. */
  17959. clone(): Texture;
  17960. /**
  17961. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17962. * @returns The JSON representation of the texture
  17963. */
  17964. serialize(): any;
  17965. /**
  17966. * Get the current class name of the texture useful for serialization or dynamic coding.
  17967. * @returns "Texture"
  17968. */
  17969. getClassName(): string;
  17970. /**
  17971. * Dispose the texture and release its associated resources.
  17972. */
  17973. dispose(): void;
  17974. /**
  17975. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17976. * @param parsedTexture Define the JSON representation of the texture
  17977. * @param scene Define the scene the parsed texture should be instantiated in
  17978. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17979. * @returns The parsed texture if successful
  17980. */
  17981. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17982. /**
  17983. * Creates a texture from its base 64 representation.
  17984. * @param data Define the base64 payload without the data: prefix
  17985. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17986. * @param scene Define the scene the texture should belong to
  17987. * @param noMipmap Forces the texture to not create mip map information if true
  17988. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17989. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17990. * @param onLoad define a callback triggered when the texture has been loaded
  17991. * @param onError define a callback triggered when an error occurred during the loading session
  17992. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17993. * @returns the created texture
  17994. */
  17995. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17996. /**
  17997. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17998. * @param data Define the base64 payload without the data: prefix
  17999. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18000. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18001. * @param scene Define the scene the texture should belong to
  18002. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18003. * @param noMipmap Forces the texture to not create mip map information if true
  18004. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18005. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18006. * @param onLoad define a callback triggered when the texture has been loaded
  18007. * @param onError define a callback triggered when an error occurred during the loading session
  18008. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18009. * @returns the created texture
  18010. */
  18011. 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;
  18012. }
  18013. }
  18014. declare module BABYLON {
  18015. interface Engine {
  18016. /**
  18017. * Creates a raw texture
  18018. * @param data defines the data to store in the texture
  18019. * @param width defines the width of the texture
  18020. * @param height defines the height of the texture
  18021. * @param format defines the format of the data
  18022. * @param generateMipMaps defines if the engine should generate the mip levels
  18023. * @param invertY defines if data must be stored with Y axis inverted
  18024. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18025. * @param compression defines the compression used (null by default)
  18026. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18027. * @returns the raw texture inside an InternalTexture
  18028. */
  18029. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18030. /**
  18031. * Update a raw texture
  18032. * @param texture defines the texture to update
  18033. * @param data defines the data to store in the texture
  18034. * @param format defines the format of the data
  18035. * @param invertY defines if data must be stored with Y axis inverted
  18036. */
  18037. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18038. /**
  18039. * Update a raw texture
  18040. * @param texture defines the texture to update
  18041. * @param data defines the data to store in the texture
  18042. * @param format defines the format of the data
  18043. * @param invertY defines if data must be stored with Y axis inverted
  18044. * @param compression defines the compression used (null by default)
  18045. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18046. */
  18047. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18048. /**
  18049. * Creates a new raw cube texture
  18050. * @param data defines the array of data to use to create each face
  18051. * @param size defines the size of the textures
  18052. * @param format defines the format of the data
  18053. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18054. * @param generateMipMaps defines if the engine should generate the mip levels
  18055. * @param invertY defines if data must be stored with Y axis inverted
  18056. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18057. * @param compression defines the compression used (null by default)
  18058. * @returns the cube texture as an InternalTexture
  18059. */
  18060. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18061. /**
  18062. * Update a raw cube texture
  18063. * @param texture defines the texture to udpdate
  18064. * @param data defines the data to store
  18065. * @param format defines the data format
  18066. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18067. * @param invertY defines if data must be stored with Y axis inverted
  18068. */
  18069. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18070. /**
  18071. * Update a raw cube texture
  18072. * @param texture defines the texture to udpdate
  18073. * @param data defines the data to store
  18074. * @param format defines the data format
  18075. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18076. * @param invertY defines if data must be stored with Y axis inverted
  18077. * @param compression defines the compression used (null by default)
  18078. */
  18079. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18080. /**
  18081. * Update a raw cube texture
  18082. * @param texture defines the texture to udpdate
  18083. * @param data defines the data to store
  18084. * @param format defines the data format
  18085. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18086. * @param invertY defines if data must be stored with Y axis inverted
  18087. * @param compression defines the compression used (null by default)
  18088. * @param level defines which level of the texture to update
  18089. */
  18090. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18091. /**
  18092. * Creates a new raw cube texture from a specified url
  18093. * @param url defines the url where the data is located
  18094. * @param scene defines the current scene
  18095. * @param size defines the size of the textures
  18096. * @param format defines the format of the data
  18097. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18098. * @param noMipmap defines if the engine should avoid generating the mip levels
  18099. * @param callback defines a callback used to extract texture data from loaded data
  18100. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18101. * @param onLoad defines a callback called when texture is loaded
  18102. * @param onError defines a callback called if there is an error
  18103. * @returns the cube texture as an InternalTexture
  18104. */
  18105. 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;
  18106. /**
  18107. * Creates a new raw cube texture from a specified url
  18108. * @param url defines the url where the data is located
  18109. * @param scene defines the current scene
  18110. * @param size defines the size of the textures
  18111. * @param format defines the format of the data
  18112. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18113. * @param noMipmap defines if the engine should avoid generating the mip levels
  18114. * @param callback defines a callback used to extract texture data from loaded data
  18115. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18116. * @param onLoad defines a callback called when texture is loaded
  18117. * @param onError defines a callback called if there is an error
  18118. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18119. * @param invertY defines if data must be stored with Y axis inverted
  18120. * @returns the cube texture as an InternalTexture
  18121. */
  18122. 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;
  18123. /**
  18124. * Creates a new raw 3D texture
  18125. * @param data defines the data used to create the texture
  18126. * @param width defines the width of the texture
  18127. * @param height defines the height of the texture
  18128. * @param depth defines the depth of the texture
  18129. * @param format defines the format of the texture
  18130. * @param generateMipMaps defines if the engine must generate mip levels
  18131. * @param invertY defines if data must be stored with Y axis inverted
  18132. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18133. * @param compression defines the compressed used (can be null)
  18134. * @param textureType defines the compressed used (can be null)
  18135. * @returns a new raw 3D texture (stored in an InternalTexture)
  18136. */
  18137. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18138. /**
  18139. * Update a raw 3D texture
  18140. * @param texture defines the texture to update
  18141. * @param data defines the data to store
  18142. * @param format defines the data format
  18143. * @param invertY defines if data must be stored with Y axis inverted
  18144. */
  18145. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18146. /**
  18147. * Update a raw 3D texture
  18148. * @param texture defines the texture to update
  18149. * @param data defines the data to store
  18150. * @param format defines the data format
  18151. * @param invertY defines if data must be stored with Y axis inverted
  18152. * @param compression defines the used compression (can be null)
  18153. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18154. */
  18155. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18156. }
  18157. }
  18158. declare module BABYLON {
  18159. /**
  18160. * Raw texture can help creating a texture directly from an array of data.
  18161. * This can be super useful if you either get the data from an uncompressed source or
  18162. * if you wish to create your texture pixel by pixel.
  18163. */
  18164. export class RawTexture extends Texture {
  18165. /**
  18166. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18167. */
  18168. format: number;
  18169. private _engine;
  18170. /**
  18171. * Instantiates a new RawTexture.
  18172. * Raw texture can help creating a texture directly from an array of data.
  18173. * This can be super useful if you either get the data from an uncompressed source or
  18174. * if you wish to create your texture pixel by pixel.
  18175. * @param data define the array of data to use to create the texture
  18176. * @param width define the width of the texture
  18177. * @param height define the height of the texture
  18178. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18179. * @param scene define the scene the texture belongs to
  18180. * @param generateMipMaps define whether mip maps should be generated or not
  18181. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18182. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18183. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18184. */
  18185. constructor(data: ArrayBufferView, width: number, height: number,
  18186. /**
  18187. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18188. */
  18189. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18190. /**
  18191. * Updates the texture underlying data.
  18192. * @param data Define the new data of the texture
  18193. */
  18194. update(data: ArrayBufferView): void;
  18195. /**
  18196. * Creates a luminance texture from some data.
  18197. * @param data Define the texture data
  18198. * @param width Define the width of the texture
  18199. * @param height Define the height of the texture
  18200. * @param scene Define the scene the texture belongs to
  18201. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18202. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18203. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18204. * @returns the luminance texture
  18205. */
  18206. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18207. /**
  18208. * Creates a luminance alpha texture from some data.
  18209. * @param data Define the texture data
  18210. * @param width Define the width of the texture
  18211. * @param height Define the height of the texture
  18212. * @param scene Define the scene the texture belongs to
  18213. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18214. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18215. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18216. * @returns the luminance alpha texture
  18217. */
  18218. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18219. /**
  18220. * Creates an alpha texture from some data.
  18221. * @param data Define the texture data
  18222. * @param width Define the width of the texture
  18223. * @param height Define the height of the texture
  18224. * @param scene Define the scene the texture belongs to
  18225. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18226. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18227. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18228. * @returns the alpha texture
  18229. */
  18230. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18231. /**
  18232. * Creates a RGB texture from some data.
  18233. * @param data Define the texture data
  18234. * @param width Define the width of the texture
  18235. * @param height Define the height of the texture
  18236. * @param scene Define the scene the texture belongs to
  18237. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18238. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18239. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18240. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18241. * @returns the RGB alpha texture
  18242. */
  18243. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18244. /**
  18245. * Creates a RGBA texture from some data.
  18246. * @param data Define the texture data
  18247. * @param width Define the width of the texture
  18248. * @param height Define the height of the texture
  18249. * @param scene Define the scene the texture belongs to
  18250. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18253. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18254. * @returns the RGBA texture
  18255. */
  18256. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18257. /**
  18258. * Creates a R texture from some data.
  18259. * @param data Define the texture data
  18260. * @param width Define the width of the texture
  18261. * @param height Define the height of the texture
  18262. * @param scene Define the scene the texture belongs to
  18263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18266. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18267. * @returns the R texture
  18268. */
  18269. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18270. }
  18271. }
  18272. declare module BABYLON {
  18273. /**
  18274. * Defines a runtime animation
  18275. */
  18276. export class RuntimeAnimation {
  18277. private _events;
  18278. /**
  18279. * The current frame of the runtime animation
  18280. */
  18281. private _currentFrame;
  18282. /**
  18283. * The animation used by the runtime animation
  18284. */
  18285. private _animation;
  18286. /**
  18287. * The target of the runtime animation
  18288. */
  18289. private _target;
  18290. /**
  18291. * The initiating animatable
  18292. */
  18293. private _host;
  18294. /**
  18295. * The original value of the runtime animation
  18296. */
  18297. private _originalValue;
  18298. /**
  18299. * The original blend value of the runtime animation
  18300. */
  18301. private _originalBlendValue;
  18302. /**
  18303. * The offsets cache of the runtime animation
  18304. */
  18305. private _offsetsCache;
  18306. /**
  18307. * The high limits cache of the runtime animation
  18308. */
  18309. private _highLimitsCache;
  18310. /**
  18311. * Specifies if the runtime animation has been stopped
  18312. */
  18313. private _stopped;
  18314. /**
  18315. * The blending factor of the runtime animation
  18316. */
  18317. private _blendingFactor;
  18318. /**
  18319. * The BabylonJS scene
  18320. */
  18321. private _scene;
  18322. /**
  18323. * The current value of the runtime animation
  18324. */
  18325. private _currentValue;
  18326. /** @hidden */ private _animationState: _IAnimationState;
  18327. /**
  18328. * The active target of the runtime animation
  18329. */
  18330. private _activeTargets;
  18331. private _currentActiveTarget;
  18332. private _directTarget;
  18333. /**
  18334. * The target path of the runtime animation
  18335. */
  18336. private _targetPath;
  18337. /**
  18338. * The weight of the runtime animation
  18339. */
  18340. private _weight;
  18341. /**
  18342. * The ratio offset of the runtime animation
  18343. */
  18344. private _ratioOffset;
  18345. /**
  18346. * The previous delay of the runtime animation
  18347. */
  18348. private _previousDelay;
  18349. /**
  18350. * The previous ratio of the runtime animation
  18351. */
  18352. private _previousRatio;
  18353. private _enableBlending;
  18354. private _keys;
  18355. private _minFrame;
  18356. private _maxFrame;
  18357. private _minValue;
  18358. private _maxValue;
  18359. private _targetIsArray;
  18360. /**
  18361. * Gets the current frame of the runtime animation
  18362. */
  18363. readonly currentFrame: number;
  18364. /**
  18365. * Gets the weight of the runtime animation
  18366. */
  18367. readonly weight: number;
  18368. /**
  18369. * Gets the current value of the runtime animation
  18370. */
  18371. readonly currentValue: any;
  18372. /**
  18373. * Gets the target path of the runtime animation
  18374. */
  18375. readonly targetPath: string;
  18376. /**
  18377. * Gets the actual target of the runtime animation
  18378. */
  18379. readonly target: any;
  18380. /** @hidden */ private _onLoop: () => void;
  18381. /**
  18382. * Create a new RuntimeAnimation object
  18383. * @param target defines the target of the animation
  18384. * @param animation defines the source animation object
  18385. * @param scene defines the hosting scene
  18386. * @param host defines the initiating Animatable
  18387. */
  18388. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18389. private _preparePath;
  18390. /**
  18391. * Gets the animation from the runtime animation
  18392. */
  18393. readonly animation: Animation;
  18394. /**
  18395. * Resets the runtime animation to the beginning
  18396. * @param restoreOriginal defines whether to restore the target property to the original value
  18397. */
  18398. reset(restoreOriginal?: boolean): void;
  18399. /**
  18400. * Specifies if the runtime animation is stopped
  18401. * @returns Boolean specifying if the runtime animation is stopped
  18402. */
  18403. isStopped(): boolean;
  18404. /**
  18405. * Disposes of the runtime animation
  18406. */
  18407. dispose(): void;
  18408. /**
  18409. * Apply the interpolated value to the target
  18410. * @param currentValue defines the value computed by the animation
  18411. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18412. */
  18413. setValue(currentValue: any, weight: number): void;
  18414. private _getOriginalValues;
  18415. private _setValue;
  18416. /**
  18417. * Gets the loop pmode of the runtime animation
  18418. * @returns Loop Mode
  18419. */
  18420. private _getCorrectLoopMode;
  18421. /**
  18422. * Move the current animation to a given frame
  18423. * @param frame defines the frame to move to
  18424. */
  18425. goToFrame(frame: number): void;
  18426. /**
  18427. * @hidden Internal use only
  18428. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18429. /**
  18430. * Execute the current animation
  18431. * @param delay defines the delay to add to the current frame
  18432. * @param from defines the lower bound of the animation range
  18433. * @param to defines the upper bound of the animation range
  18434. * @param loop defines if the current animation must loop
  18435. * @param speedRatio defines the current speed ratio
  18436. * @param weight defines the weight of the animation (default is -1 so no weight)
  18437. * @param onLoop optional callback called when animation loops
  18438. * @returns a boolean indicating if the animation is running
  18439. */
  18440. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18441. }
  18442. }
  18443. declare module BABYLON {
  18444. /**
  18445. * Class used to store an actual running animation
  18446. */
  18447. export class Animatable {
  18448. /** defines the target object */
  18449. target: any;
  18450. /** defines the starting frame number (default is 0) */
  18451. fromFrame: number;
  18452. /** defines the ending frame number (default is 100) */
  18453. toFrame: number;
  18454. /** defines if the animation must loop (default is false) */
  18455. loopAnimation: boolean;
  18456. /** defines a callback to call when animation ends if it is not looping */
  18457. onAnimationEnd?: (() => void) | null | undefined;
  18458. /** defines a callback to call when animation loops */
  18459. onAnimationLoop?: (() => void) | null | undefined;
  18460. private _localDelayOffset;
  18461. private _pausedDelay;
  18462. private _runtimeAnimations;
  18463. private _paused;
  18464. private _scene;
  18465. private _speedRatio;
  18466. private _weight;
  18467. private _syncRoot;
  18468. /**
  18469. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18470. * This will only apply for non looping animation (default is true)
  18471. */
  18472. disposeOnEnd: boolean;
  18473. /**
  18474. * Gets a boolean indicating if the animation has started
  18475. */
  18476. animationStarted: boolean;
  18477. /**
  18478. * Observer raised when the animation ends
  18479. */
  18480. onAnimationEndObservable: Observable<Animatable>;
  18481. /**
  18482. * Observer raised when the animation loops
  18483. */
  18484. onAnimationLoopObservable: Observable<Animatable>;
  18485. /**
  18486. * Gets the root Animatable used to synchronize and normalize animations
  18487. */
  18488. readonly syncRoot: Nullable<Animatable>;
  18489. /**
  18490. * Gets the current frame of the first RuntimeAnimation
  18491. * Used to synchronize Animatables
  18492. */
  18493. readonly masterFrame: number;
  18494. /**
  18495. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18496. */
  18497. weight: number;
  18498. /**
  18499. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18500. */
  18501. speedRatio: number;
  18502. /**
  18503. * Creates a new Animatable
  18504. * @param scene defines the hosting scene
  18505. * @param target defines the target object
  18506. * @param fromFrame defines the starting frame number (default is 0)
  18507. * @param toFrame defines the ending frame number (default is 100)
  18508. * @param loopAnimation defines if the animation must loop (default is false)
  18509. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18510. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18511. * @param animations defines a group of animation to add to the new Animatable
  18512. * @param onAnimationLoop defines a callback to call when animation loops
  18513. */
  18514. constructor(scene: Scene,
  18515. /** defines the target object */
  18516. target: any,
  18517. /** defines the starting frame number (default is 0) */
  18518. fromFrame?: number,
  18519. /** defines the ending frame number (default is 100) */
  18520. toFrame?: number,
  18521. /** defines if the animation must loop (default is false) */
  18522. loopAnimation?: boolean, speedRatio?: number,
  18523. /** defines a callback to call when animation ends if it is not looping */
  18524. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18525. /** defines a callback to call when animation loops */
  18526. onAnimationLoop?: (() => void) | null | undefined);
  18527. /**
  18528. * Synchronize and normalize current Animatable with a source Animatable
  18529. * This is useful when using animation weights and when animations are not of the same length
  18530. * @param root defines the root Animatable to synchronize with
  18531. * @returns the current Animatable
  18532. */
  18533. syncWith(root: Animatable): Animatable;
  18534. /**
  18535. * Gets the list of runtime animations
  18536. * @returns an array of RuntimeAnimation
  18537. */
  18538. getAnimations(): RuntimeAnimation[];
  18539. /**
  18540. * Adds more animations to the current animatable
  18541. * @param target defines the target of the animations
  18542. * @param animations defines the new animations to add
  18543. */
  18544. appendAnimations(target: any, animations: Animation[]): void;
  18545. /**
  18546. * Gets the source animation for a specific property
  18547. * @param property defines the propertyu to look for
  18548. * @returns null or the source animation for the given property
  18549. */
  18550. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18551. /**
  18552. * Gets the runtime animation for a specific property
  18553. * @param property defines the propertyu to look for
  18554. * @returns null or the runtime animation for the given property
  18555. */
  18556. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18557. /**
  18558. * Resets the animatable to its original state
  18559. */
  18560. reset(): void;
  18561. /**
  18562. * Allows the animatable to blend with current running animations
  18563. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18564. * @param blendingSpeed defines the blending speed to use
  18565. */
  18566. enableBlending(blendingSpeed: number): void;
  18567. /**
  18568. * Disable animation blending
  18569. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18570. */
  18571. disableBlending(): void;
  18572. /**
  18573. * Jump directly to a given frame
  18574. * @param frame defines the frame to jump to
  18575. */
  18576. goToFrame(frame: number): void;
  18577. /**
  18578. * Pause the animation
  18579. */
  18580. pause(): void;
  18581. /**
  18582. * Restart the animation
  18583. */
  18584. restart(): void;
  18585. private _raiseOnAnimationEnd;
  18586. /**
  18587. * Stop and delete the current animation
  18588. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18589. * @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)
  18590. */
  18591. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18592. /**
  18593. * Wait asynchronously for the animation to end
  18594. * @returns a promise which will be fullfilled when the animation ends
  18595. */
  18596. waitAsync(): Promise<Animatable>;
  18597. /** @hidden */ private _animate(delay: number): boolean;
  18598. }
  18599. interface Scene {
  18600. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18601. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  18602. totalWeight: number;
  18603. animations: RuntimeAnimation[];
  18604. originalValue: Matrix;
  18605. }): any;
  18606. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  18607. totalWeight: number;
  18608. animations: RuntimeAnimation[];
  18609. originalValue: Quaternion;
  18610. }, refQuaternion: Quaternion): Quaternion;
  18611. /** @hidden */ private _processLateAnimationBindings(): void;
  18612. /**
  18613. * Will start the animation sequence of a given target
  18614. * @param target defines the target
  18615. * @param from defines from which frame should animation start
  18616. * @param to defines until which frame should animation run.
  18617. * @param weight defines the weight to apply to the animation (1.0 by default)
  18618. * @param loop defines if the animation loops
  18619. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18620. * @param onAnimationEnd defines the function to be executed when the animation ends
  18621. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18622. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18623. * @param onAnimationLoop defines the callback to call when an animation loops
  18624. * @returns the animatable object created for this animation
  18625. */
  18626. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18627. /**
  18628. * Will start the animation sequence of a given target
  18629. * @param target defines the target
  18630. * @param from defines from which frame should animation start
  18631. * @param to defines until which frame should animation run.
  18632. * @param loop defines if the animation loops
  18633. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18634. * @param onAnimationEnd defines the function to be executed when the animation ends
  18635. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18636. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18637. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18638. * @param onAnimationLoop defines the callback to call when an animation loops
  18639. * @returns the animatable object created for this animation
  18640. */
  18641. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18642. /**
  18643. * Will start the animation sequence of a given target and its hierarchy
  18644. * @param target defines the target
  18645. * @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.
  18646. * @param from defines from which frame should animation start
  18647. * @param to defines until which frame should animation run.
  18648. * @param loop defines if the animation loops
  18649. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18650. * @param onAnimationEnd defines the function to be executed when the animation ends
  18651. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18652. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18653. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18654. * @param onAnimationLoop defines the callback to call when an animation loops
  18655. * @returns the list of created animatables
  18656. */
  18657. 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[];
  18658. /**
  18659. * Begin a new animation on a given node
  18660. * @param target defines the target where the animation will take place
  18661. * @param animations defines the list of animations to start
  18662. * @param from defines the initial value
  18663. * @param to defines the final value
  18664. * @param loop defines if you want animation to loop (off by default)
  18665. * @param speedRatio defines the speed ratio to apply to all animations
  18666. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18667. * @param onAnimationLoop defines the callback to call when an animation loops
  18668. * @returns the list of created animatables
  18669. */
  18670. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18671. /**
  18672. * Begin a new animation on a given node and its hierarchy
  18673. * @param target defines the root node where the animation will take place
  18674. * @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.
  18675. * @param animations defines the list of animations to start
  18676. * @param from defines the initial value
  18677. * @param to defines the final value
  18678. * @param loop defines if you want animation to loop (off by default)
  18679. * @param speedRatio defines the speed ratio to apply to all animations
  18680. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18681. * @param onAnimationLoop defines the callback to call when an animation loops
  18682. * @returns the list of animatables created for all nodes
  18683. */
  18684. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18685. /**
  18686. * Gets the animatable associated with a specific target
  18687. * @param target defines the target of the animatable
  18688. * @returns the required animatable if found
  18689. */
  18690. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18691. /**
  18692. * Gets all animatables associated with a given target
  18693. * @param target defines the target to look animatables for
  18694. * @returns an array of Animatables
  18695. */
  18696. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18697. /**
  18698. * Stops and removes all animations that have been applied to the scene
  18699. */
  18700. stopAllAnimations(): void;
  18701. }
  18702. interface Bone {
  18703. /**
  18704. * Copy an animation range from another bone
  18705. * @param source defines the source bone
  18706. * @param rangeName defines the range name to copy
  18707. * @param frameOffset defines the frame offset
  18708. * @param rescaleAsRequired defines if rescaling must be applied if required
  18709. * @param skelDimensionsRatio defines the scaling ratio
  18710. * @returns true if operation was successful
  18711. */
  18712. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18713. }
  18714. }
  18715. declare module BABYLON {
  18716. /**
  18717. * Class used to handle skinning animations
  18718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18719. */
  18720. export class Skeleton implements IAnimatable {
  18721. /** defines the skeleton name */
  18722. name: string;
  18723. /** defines the skeleton Id */
  18724. id: string;
  18725. /**
  18726. * Defines the list of child bones
  18727. */
  18728. bones: Bone[];
  18729. /**
  18730. * Defines an estimate of the dimension of the skeleton at rest
  18731. */
  18732. dimensionsAtRest: Vector3;
  18733. /**
  18734. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18735. */
  18736. needInitialSkinMatrix: boolean;
  18737. /**
  18738. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18739. */
  18740. overrideMesh: Nullable<AbstractMesh>;
  18741. /**
  18742. * Gets the list of animations attached to this skeleton
  18743. */
  18744. animations: Array<Animation>;
  18745. private _scene;
  18746. private _isDirty;
  18747. private _transformMatrices;
  18748. private _transformMatrixTexture;
  18749. private _meshesWithPoseMatrix;
  18750. private _animatables;
  18751. private _identity;
  18752. private _synchronizedWithMesh;
  18753. private _ranges;
  18754. private _lastAbsoluteTransformsUpdateId;
  18755. private _canUseTextureForBones;
  18756. private _uniqueId;
  18757. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  18758. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  18759. /**
  18760. * Specifies if the skeleton should be serialized
  18761. */
  18762. doNotSerialize: boolean;
  18763. private _useTextureToStoreBoneMatrices;
  18764. /**
  18765. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18766. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18767. */
  18768. useTextureToStoreBoneMatrices: boolean;
  18769. private _animationPropertiesOverride;
  18770. /**
  18771. * Gets or sets the animation properties override
  18772. */
  18773. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18774. /**
  18775. * List of inspectable custom properties (used by the Inspector)
  18776. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18777. */
  18778. inspectableCustomProperties: IInspectable[];
  18779. /**
  18780. * An observable triggered before computing the skeleton's matrices
  18781. */
  18782. onBeforeComputeObservable: Observable<Skeleton>;
  18783. /**
  18784. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18785. */
  18786. readonly isUsingTextureForMatrices: boolean;
  18787. /**
  18788. * Gets the unique ID of this skeleton
  18789. */
  18790. readonly uniqueId: number;
  18791. /**
  18792. * Creates a new skeleton
  18793. * @param name defines the skeleton name
  18794. * @param id defines the skeleton Id
  18795. * @param scene defines the hosting scene
  18796. */
  18797. constructor(
  18798. /** defines the skeleton name */
  18799. name: string,
  18800. /** defines the skeleton Id */
  18801. id: string, scene: Scene);
  18802. /**
  18803. * Gets the current object class name.
  18804. * @return the class name
  18805. */
  18806. getClassName(): string;
  18807. /**
  18808. * Returns an array containing the root bones
  18809. * @returns an array containing the root bones
  18810. */
  18811. getChildren(): Array<Bone>;
  18812. /**
  18813. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18814. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18815. * @returns a Float32Array containing matrices data
  18816. */
  18817. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18818. /**
  18819. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18820. * @returns a raw texture containing the data
  18821. */
  18822. getTransformMatrixTexture(): Nullable<RawTexture>;
  18823. /**
  18824. * Gets the current hosting scene
  18825. * @returns a scene object
  18826. */
  18827. getScene(): Scene;
  18828. /**
  18829. * Gets a string representing the current skeleton data
  18830. * @param fullDetails defines a boolean indicating if we want a verbose version
  18831. * @returns a string representing the current skeleton data
  18832. */
  18833. toString(fullDetails?: boolean): string;
  18834. /**
  18835. * Get bone's index searching by name
  18836. * @param name defines bone's name to search for
  18837. * @return the indice of the bone. Returns -1 if not found
  18838. */
  18839. getBoneIndexByName(name: string): number;
  18840. /**
  18841. * Creater a new animation range
  18842. * @param name defines the name of the range
  18843. * @param from defines the start key
  18844. * @param to defines the end key
  18845. */
  18846. createAnimationRange(name: string, from: number, to: number): void;
  18847. /**
  18848. * Delete a specific animation range
  18849. * @param name defines the name of the range
  18850. * @param deleteFrames defines if frames must be removed as well
  18851. */
  18852. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18853. /**
  18854. * Gets a specific animation range
  18855. * @param name defines the name of the range to look for
  18856. * @returns the requested animation range or null if not found
  18857. */
  18858. getAnimationRange(name: string): Nullable<AnimationRange>;
  18859. /**
  18860. * Gets the list of all animation ranges defined on this skeleton
  18861. * @returns an array
  18862. */
  18863. getAnimationRanges(): Nullable<AnimationRange>[];
  18864. /**
  18865. * Copy animation range from a source skeleton.
  18866. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18867. * @param source defines the source skeleton
  18868. * @param name defines the name of the range to copy
  18869. * @param rescaleAsRequired defines if rescaling must be applied if required
  18870. * @returns true if operation was successful
  18871. */
  18872. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18873. /**
  18874. * Forces the skeleton to go to rest pose
  18875. */
  18876. returnToRest(): void;
  18877. private _getHighestAnimationFrame;
  18878. /**
  18879. * Begin a specific animation range
  18880. * @param name defines the name of the range to start
  18881. * @param loop defines if looping must be turned on (false by default)
  18882. * @param speedRatio defines the speed ratio to apply (1 by default)
  18883. * @param onAnimationEnd defines a callback which will be called when animation will end
  18884. * @returns a new animatable
  18885. */
  18886. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18887. /** @hidden */ private _markAsDirty(): void;
  18888. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18889. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18890. private _computeTransformMatrices;
  18891. /**
  18892. * Build all resources required to render a skeleton
  18893. */
  18894. prepare(): void;
  18895. /**
  18896. * Gets the list of animatables currently running for this skeleton
  18897. * @returns an array of animatables
  18898. */
  18899. getAnimatables(): IAnimatable[];
  18900. /**
  18901. * Clone the current skeleton
  18902. * @param name defines the name of the new skeleton
  18903. * @param id defines the id of the new skeleton
  18904. * @returns the new skeleton
  18905. */
  18906. clone(name: string, id: string): Skeleton;
  18907. /**
  18908. * Enable animation blending for this skeleton
  18909. * @param blendingSpeed defines the blending speed to apply
  18910. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18911. */
  18912. enableBlending(blendingSpeed?: number): void;
  18913. /**
  18914. * Releases all resources associated with the current skeleton
  18915. */
  18916. dispose(): void;
  18917. /**
  18918. * Serialize the skeleton in a JSON object
  18919. * @returns a JSON object
  18920. */
  18921. serialize(): any;
  18922. /**
  18923. * Creates a new skeleton from serialized data
  18924. * @param parsedSkeleton defines the serialized data
  18925. * @param scene defines the hosting scene
  18926. * @returns a new skeleton
  18927. */
  18928. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18929. /**
  18930. * Compute all node absolute transforms
  18931. * @param forceUpdate defines if computation must be done even if cache is up to date
  18932. */
  18933. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18934. /**
  18935. * Gets the root pose matrix
  18936. * @returns a matrix
  18937. */
  18938. getPoseMatrix(): Nullable<Matrix>;
  18939. /**
  18940. * Sorts bones per internal index
  18941. */
  18942. sortBones(): void;
  18943. private _sortBones;
  18944. }
  18945. }
  18946. declare module BABYLON {
  18947. /**
  18948. * Defines a target to use with MorphTargetManager
  18949. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18950. */
  18951. export class MorphTarget implements IAnimatable {
  18952. /** defines the name of the target */
  18953. name: string;
  18954. /**
  18955. * Gets or sets the list of animations
  18956. */
  18957. animations: Animation[];
  18958. private _scene;
  18959. private _positions;
  18960. private _normals;
  18961. private _tangents;
  18962. private _influence;
  18963. /**
  18964. * Observable raised when the influence changes
  18965. */
  18966. onInfluenceChanged: Observable<boolean>;
  18967. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  18968. /**
  18969. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18970. */
  18971. influence: number;
  18972. /**
  18973. * Gets or sets the id of the morph Target
  18974. */
  18975. id: string;
  18976. private _animationPropertiesOverride;
  18977. /**
  18978. * Gets or sets the animation properties override
  18979. */
  18980. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18981. /**
  18982. * Creates a new MorphTarget
  18983. * @param name defines the name of the target
  18984. * @param influence defines the influence to use
  18985. * @param scene defines the scene the morphtarget belongs to
  18986. */
  18987. constructor(
  18988. /** defines the name of the target */
  18989. name: string, influence?: number, scene?: Nullable<Scene>);
  18990. /**
  18991. * Gets a boolean defining if the target contains position data
  18992. */
  18993. readonly hasPositions: boolean;
  18994. /**
  18995. * Gets a boolean defining if the target contains normal data
  18996. */
  18997. readonly hasNormals: boolean;
  18998. /**
  18999. * Gets a boolean defining if the target contains tangent data
  19000. */
  19001. readonly hasTangents: boolean;
  19002. /**
  19003. * Affects position data to this target
  19004. * @param data defines the position data to use
  19005. */
  19006. setPositions(data: Nullable<FloatArray>): void;
  19007. /**
  19008. * Gets the position data stored in this target
  19009. * @returns a FloatArray containing the position data (or null if not present)
  19010. */
  19011. getPositions(): Nullable<FloatArray>;
  19012. /**
  19013. * Affects normal data to this target
  19014. * @param data defines the normal data to use
  19015. */
  19016. setNormals(data: Nullable<FloatArray>): void;
  19017. /**
  19018. * Gets the normal data stored in this target
  19019. * @returns a FloatArray containing the normal data (or null if not present)
  19020. */
  19021. getNormals(): Nullable<FloatArray>;
  19022. /**
  19023. * Affects tangent data to this target
  19024. * @param data defines the tangent data to use
  19025. */
  19026. setTangents(data: Nullable<FloatArray>): void;
  19027. /**
  19028. * Gets the tangent data stored in this target
  19029. * @returns a FloatArray containing the tangent data (or null if not present)
  19030. */
  19031. getTangents(): Nullable<FloatArray>;
  19032. /**
  19033. * Serializes the current target into a Serialization object
  19034. * @returns the serialized object
  19035. */
  19036. serialize(): any;
  19037. /**
  19038. * Returns the string "MorphTarget"
  19039. * @returns "MorphTarget"
  19040. */
  19041. getClassName(): string;
  19042. /**
  19043. * Creates a new target from serialized data
  19044. * @param serializationObject defines the serialized data to use
  19045. * @returns a new MorphTarget
  19046. */
  19047. static Parse(serializationObject: any): MorphTarget;
  19048. /**
  19049. * Creates a MorphTarget from mesh data
  19050. * @param mesh defines the source mesh
  19051. * @param name defines the name to use for the new target
  19052. * @param influence defines the influence to attach to the target
  19053. * @returns a new MorphTarget
  19054. */
  19055. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19056. }
  19057. }
  19058. declare module BABYLON {
  19059. /**
  19060. * This class is used to deform meshes using morphing between different targets
  19061. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19062. */
  19063. export class MorphTargetManager {
  19064. private _targets;
  19065. private _targetInfluenceChangedObservers;
  19066. private _targetDataLayoutChangedObservers;
  19067. private _activeTargets;
  19068. private _scene;
  19069. private _influences;
  19070. private _supportsNormals;
  19071. private _supportsTangents;
  19072. private _vertexCount;
  19073. private _uniqueId;
  19074. private _tempInfluences;
  19075. /**
  19076. * Creates a new MorphTargetManager
  19077. * @param scene defines the current scene
  19078. */
  19079. constructor(scene?: Nullable<Scene>);
  19080. /**
  19081. * Gets the unique ID of this manager
  19082. */
  19083. readonly uniqueId: number;
  19084. /**
  19085. * Gets the number of vertices handled by this manager
  19086. */
  19087. readonly vertexCount: number;
  19088. /**
  19089. * Gets a boolean indicating if this manager supports morphing of normals
  19090. */
  19091. readonly supportsNormals: boolean;
  19092. /**
  19093. * Gets a boolean indicating if this manager supports morphing of tangents
  19094. */
  19095. readonly supportsTangents: boolean;
  19096. /**
  19097. * Gets the number of targets stored in this manager
  19098. */
  19099. readonly numTargets: number;
  19100. /**
  19101. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19102. */
  19103. readonly numInfluencers: number;
  19104. /**
  19105. * Gets the list of influences (one per target)
  19106. */
  19107. readonly influences: Float32Array;
  19108. /**
  19109. * Gets the active target at specified index. An active target is a target with an influence > 0
  19110. * @param index defines the index to check
  19111. * @returns the requested target
  19112. */
  19113. getActiveTarget(index: number): MorphTarget;
  19114. /**
  19115. * Gets the target at specified index
  19116. * @param index defines the index to check
  19117. * @returns the requested target
  19118. */
  19119. getTarget(index: number): MorphTarget;
  19120. /**
  19121. * Add a new target to this manager
  19122. * @param target defines the target to add
  19123. */
  19124. addTarget(target: MorphTarget): void;
  19125. /**
  19126. * Removes a target from the manager
  19127. * @param target defines the target to remove
  19128. */
  19129. removeTarget(target: MorphTarget): void;
  19130. /**
  19131. * Serializes the current manager into a Serialization object
  19132. * @returns the serialized object
  19133. */
  19134. serialize(): any;
  19135. private _syncActiveTargets;
  19136. /**
  19137. * Syncrhonize the targets with all the meshes using this morph target manager
  19138. */
  19139. synchronize(): void;
  19140. /**
  19141. * Creates a new MorphTargetManager from serialized data
  19142. * @param serializationObject defines the serialized data
  19143. * @param scene defines the hosting scene
  19144. * @returns the new MorphTargetManager
  19145. */
  19146. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19147. }
  19148. }
  19149. declare module BABYLON {
  19150. /**
  19151. * Class used to represent a specific level of detail of a mesh
  19152. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19153. */
  19154. export class MeshLODLevel {
  19155. /** Defines the distance where this level should star being displayed */
  19156. distance: number;
  19157. /** Defines the mesh to use to render this level */
  19158. mesh: Nullable<Mesh>;
  19159. /**
  19160. * Creates a new LOD level
  19161. * @param distance defines the distance where this level should star being displayed
  19162. * @param mesh defines the mesh to use to render this level
  19163. */
  19164. constructor(
  19165. /** Defines the distance where this level should star being displayed */
  19166. distance: number,
  19167. /** Defines the mesh to use to render this level */
  19168. mesh: Nullable<Mesh>);
  19169. }
  19170. }
  19171. declare module BABYLON {
  19172. /**
  19173. * Mesh representing the gorund
  19174. */
  19175. export class GroundMesh extends Mesh {
  19176. /** If octree should be generated */
  19177. generateOctree: boolean;
  19178. private _heightQuads;
  19179. /** @hidden */ private _subdivisionsX: number;
  19180. /** @hidden */ private _subdivisionsY: number;
  19181. /** @hidden */ private _width: number;
  19182. /** @hidden */ private _height: number;
  19183. /** @hidden */ private _minX: number;
  19184. /** @hidden */ private _maxX: number;
  19185. /** @hidden */ private _minZ: number;
  19186. /** @hidden */ private _maxZ: number;
  19187. constructor(name: string, scene: Scene);
  19188. /**
  19189. * "GroundMesh"
  19190. * @returns "GroundMesh"
  19191. */
  19192. getClassName(): string;
  19193. /**
  19194. * The minimum of x and y subdivisions
  19195. */
  19196. readonly subdivisions: number;
  19197. /**
  19198. * X subdivisions
  19199. */
  19200. readonly subdivisionsX: number;
  19201. /**
  19202. * Y subdivisions
  19203. */
  19204. readonly subdivisionsY: number;
  19205. /**
  19206. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19207. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19208. * @param chunksCount the number of subdivisions for x and y
  19209. * @param octreeBlocksSize (Default: 32)
  19210. */
  19211. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19212. /**
  19213. * Returns a height (y) value in the Worl system :
  19214. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19215. * @param x x coordinate
  19216. * @param z z coordinate
  19217. * @returns the ground y position if (x, z) are outside the ground surface.
  19218. */
  19219. getHeightAtCoordinates(x: number, z: number): number;
  19220. /**
  19221. * Returns a normalized vector (Vector3) orthogonal to the ground
  19222. * at the ground coordinates (x, z) expressed in the World system.
  19223. * @param x x coordinate
  19224. * @param z z coordinate
  19225. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19226. */
  19227. getNormalAtCoordinates(x: number, z: number): Vector3;
  19228. /**
  19229. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19230. * at the ground coordinates (x, z) expressed in the World system.
  19231. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19232. * @param x x coordinate
  19233. * @param z z coordinate
  19234. * @param ref vector to store the result
  19235. * @returns the GroundMesh.
  19236. */
  19237. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19238. /**
  19239. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19240. * if the ground has been updated.
  19241. * This can be used in the render loop.
  19242. * @returns the GroundMesh.
  19243. */
  19244. updateCoordinateHeights(): GroundMesh;
  19245. private _getFacetAt;
  19246. private _initHeightQuads;
  19247. private _computeHeightQuads;
  19248. /**
  19249. * Serializes this ground mesh
  19250. * @param serializationObject object to write serialization to
  19251. */
  19252. serialize(serializationObject: any): void;
  19253. /**
  19254. * Parses a serialized ground mesh
  19255. * @param parsedMesh the serialized mesh
  19256. * @param scene the scene to create the ground mesh in
  19257. * @returns the created ground mesh
  19258. */
  19259. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19260. }
  19261. }
  19262. declare module BABYLON {
  19263. /**
  19264. * Interface for Physics-Joint data
  19265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19266. */
  19267. export interface PhysicsJointData {
  19268. /**
  19269. * The main pivot of the joint
  19270. */
  19271. mainPivot?: Vector3;
  19272. /**
  19273. * The connected pivot of the joint
  19274. */
  19275. connectedPivot?: Vector3;
  19276. /**
  19277. * The main axis of the joint
  19278. */
  19279. mainAxis?: Vector3;
  19280. /**
  19281. * The connected axis of the joint
  19282. */
  19283. connectedAxis?: Vector3;
  19284. /**
  19285. * The collision of the joint
  19286. */
  19287. collision?: boolean;
  19288. /**
  19289. * Native Oimo/Cannon/Energy data
  19290. */
  19291. nativeParams?: any;
  19292. }
  19293. /**
  19294. * This is a holder class for the physics joint created by the physics plugin
  19295. * It holds a set of functions to control the underlying joint
  19296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19297. */
  19298. export class PhysicsJoint {
  19299. /**
  19300. * The type of the physics joint
  19301. */
  19302. type: number;
  19303. /**
  19304. * The data for the physics joint
  19305. */
  19306. jointData: PhysicsJointData;
  19307. private _physicsJoint;
  19308. protected _physicsPlugin: IPhysicsEnginePlugin;
  19309. /**
  19310. * Initializes the physics joint
  19311. * @param type The type of the physics joint
  19312. * @param jointData The data for the physics joint
  19313. */
  19314. constructor(
  19315. /**
  19316. * The type of the physics joint
  19317. */
  19318. type: number,
  19319. /**
  19320. * The data for the physics joint
  19321. */
  19322. jointData: PhysicsJointData);
  19323. /**
  19324. * Gets the physics joint
  19325. */
  19326. /**
  19327. * Sets the physics joint
  19328. */
  19329. physicsJoint: any;
  19330. /**
  19331. * Sets the physics plugin
  19332. */
  19333. physicsPlugin: IPhysicsEnginePlugin;
  19334. /**
  19335. * Execute a function that is physics-plugin specific.
  19336. * @param {Function} func the function that will be executed.
  19337. * It accepts two parameters: the physics world and the physics joint
  19338. */
  19339. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19340. /**
  19341. * Distance-Joint type
  19342. */
  19343. static DistanceJoint: number;
  19344. /**
  19345. * Hinge-Joint type
  19346. */
  19347. static HingeJoint: number;
  19348. /**
  19349. * Ball-and-Socket joint type
  19350. */
  19351. static BallAndSocketJoint: number;
  19352. /**
  19353. * Wheel-Joint type
  19354. */
  19355. static WheelJoint: number;
  19356. /**
  19357. * Slider-Joint type
  19358. */
  19359. static SliderJoint: number;
  19360. /**
  19361. * Prismatic-Joint type
  19362. */
  19363. static PrismaticJoint: number;
  19364. /**
  19365. * Universal-Joint type
  19366. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19367. */
  19368. static UniversalJoint: number;
  19369. /**
  19370. * Hinge-Joint 2 type
  19371. */
  19372. static Hinge2Joint: number;
  19373. /**
  19374. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19375. */
  19376. static PointToPointJoint: number;
  19377. /**
  19378. * Spring-Joint type
  19379. */
  19380. static SpringJoint: number;
  19381. /**
  19382. * Lock-Joint type
  19383. */
  19384. static LockJoint: number;
  19385. }
  19386. /**
  19387. * A class representing a physics distance joint
  19388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19389. */
  19390. export class DistanceJoint extends PhysicsJoint {
  19391. /**
  19392. *
  19393. * @param jointData The data for the Distance-Joint
  19394. */
  19395. constructor(jointData: DistanceJointData);
  19396. /**
  19397. * Update the predefined distance.
  19398. * @param maxDistance The maximum preferred distance
  19399. * @param minDistance The minimum preferred distance
  19400. */
  19401. updateDistance(maxDistance: number, minDistance?: number): void;
  19402. }
  19403. /**
  19404. * Represents a Motor-Enabled Joint
  19405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19406. */
  19407. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19408. /**
  19409. * Initializes the Motor-Enabled Joint
  19410. * @param type The type of the joint
  19411. * @param jointData The physica joint data for the joint
  19412. */
  19413. constructor(type: number, jointData: PhysicsJointData);
  19414. /**
  19415. * Set the motor values.
  19416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19417. * @param force the force to apply
  19418. * @param maxForce max force for this motor.
  19419. */
  19420. setMotor(force?: number, maxForce?: number): void;
  19421. /**
  19422. * Set the motor's limits.
  19423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19424. * @param upperLimit The upper limit of the motor
  19425. * @param lowerLimit The lower limit of the motor
  19426. */
  19427. setLimit(upperLimit: number, lowerLimit?: number): void;
  19428. }
  19429. /**
  19430. * This class represents a single physics Hinge-Joint
  19431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19432. */
  19433. export class HingeJoint extends MotorEnabledJoint {
  19434. /**
  19435. * Initializes the Hinge-Joint
  19436. * @param jointData The joint data for the Hinge-Joint
  19437. */
  19438. constructor(jointData: PhysicsJointData);
  19439. /**
  19440. * Set the motor values.
  19441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19442. * @param {number} force the force to apply
  19443. * @param {number} maxForce max force for this motor.
  19444. */
  19445. setMotor(force?: number, maxForce?: number): void;
  19446. /**
  19447. * Set the motor's limits.
  19448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19449. * @param upperLimit The upper limit of the motor
  19450. * @param lowerLimit The lower limit of the motor
  19451. */
  19452. setLimit(upperLimit: number, lowerLimit?: number): void;
  19453. }
  19454. /**
  19455. * This class represents a dual hinge physics joint (same as wheel joint)
  19456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19457. */
  19458. export class Hinge2Joint extends MotorEnabledJoint {
  19459. /**
  19460. * Initializes the Hinge2-Joint
  19461. * @param jointData The joint data for the Hinge2-Joint
  19462. */
  19463. constructor(jointData: PhysicsJointData);
  19464. /**
  19465. * Set the motor values.
  19466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19467. * @param {number} targetSpeed the speed the motor is to reach
  19468. * @param {number} maxForce max force for this motor.
  19469. * @param {motorIndex} the motor's index, 0 or 1.
  19470. */
  19471. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19472. /**
  19473. * Set the motor limits.
  19474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19475. * @param {number} upperLimit the upper limit
  19476. * @param {number} lowerLimit lower limit
  19477. * @param {motorIndex} the motor's index, 0 or 1.
  19478. */
  19479. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19480. }
  19481. /**
  19482. * Interface for a motor enabled joint
  19483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19484. */
  19485. export interface IMotorEnabledJoint {
  19486. /**
  19487. * Physics joint
  19488. */
  19489. physicsJoint: any;
  19490. /**
  19491. * Sets the motor of the motor-enabled joint
  19492. * @param force The force of the motor
  19493. * @param maxForce The maximum force of the motor
  19494. * @param motorIndex The index of the motor
  19495. */
  19496. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19497. /**
  19498. * Sets the limit of the motor
  19499. * @param upperLimit The upper limit of the motor
  19500. * @param lowerLimit The lower limit of the motor
  19501. * @param motorIndex The index of the motor
  19502. */
  19503. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19504. }
  19505. /**
  19506. * Joint data for a Distance-Joint
  19507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19508. */
  19509. export interface DistanceJointData extends PhysicsJointData {
  19510. /**
  19511. * Max distance the 2 joint objects can be apart
  19512. */
  19513. maxDistance: number;
  19514. }
  19515. /**
  19516. * Joint data from a spring joint
  19517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19518. */
  19519. export interface SpringJointData extends PhysicsJointData {
  19520. /**
  19521. * Length of the spring
  19522. */
  19523. length: number;
  19524. /**
  19525. * Stiffness of the spring
  19526. */
  19527. stiffness: number;
  19528. /**
  19529. * Damping of the spring
  19530. */
  19531. damping: number;
  19532. /** this callback will be called when applying the force to the impostors. */
  19533. forceApplicationCallback: () => void;
  19534. }
  19535. }
  19536. declare module BABYLON {
  19537. /**
  19538. * Holds the data for the raycast result
  19539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19540. */
  19541. export class PhysicsRaycastResult {
  19542. private _hasHit;
  19543. private _hitDistance;
  19544. private _hitNormalWorld;
  19545. private _hitPointWorld;
  19546. private _rayFromWorld;
  19547. private _rayToWorld;
  19548. /**
  19549. * Gets if there was a hit
  19550. */
  19551. readonly hasHit: boolean;
  19552. /**
  19553. * Gets the distance from the hit
  19554. */
  19555. readonly hitDistance: number;
  19556. /**
  19557. * Gets the hit normal/direction in the world
  19558. */
  19559. readonly hitNormalWorld: Vector3;
  19560. /**
  19561. * Gets the hit point in the world
  19562. */
  19563. readonly hitPointWorld: Vector3;
  19564. /**
  19565. * Gets the ray "start point" of the ray in the world
  19566. */
  19567. readonly rayFromWorld: Vector3;
  19568. /**
  19569. * Gets the ray "end point" of the ray in the world
  19570. */
  19571. readonly rayToWorld: Vector3;
  19572. /**
  19573. * Sets the hit data (normal & point in world space)
  19574. * @param hitNormalWorld defines the normal in world space
  19575. * @param hitPointWorld defines the point in world space
  19576. */
  19577. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19578. /**
  19579. * Sets the distance from the start point to the hit point
  19580. * @param distance
  19581. */
  19582. setHitDistance(distance: number): void;
  19583. /**
  19584. * Calculates the distance manually
  19585. */
  19586. calculateHitDistance(): void;
  19587. /**
  19588. * Resets all the values to default
  19589. * @param from The from point on world space
  19590. * @param to The to point on world space
  19591. */
  19592. reset(from?: Vector3, to?: Vector3): void;
  19593. }
  19594. /**
  19595. * Interface for the size containing width and height
  19596. */
  19597. interface IXYZ {
  19598. /**
  19599. * X
  19600. */
  19601. x: number;
  19602. /**
  19603. * Y
  19604. */
  19605. y: number;
  19606. /**
  19607. * Z
  19608. */
  19609. z: number;
  19610. }
  19611. }
  19612. declare module BABYLON {
  19613. /**
  19614. * Interface used to describe a physics joint
  19615. */
  19616. export interface PhysicsImpostorJoint {
  19617. /** Defines the main impostor to which the joint is linked */
  19618. mainImpostor: PhysicsImpostor;
  19619. /** Defines the impostor that is connected to the main impostor using this joint */
  19620. connectedImpostor: PhysicsImpostor;
  19621. /** Defines the joint itself */
  19622. joint: PhysicsJoint;
  19623. }
  19624. /** @hidden */
  19625. export interface IPhysicsEnginePlugin {
  19626. world: any;
  19627. name: string;
  19628. setGravity(gravity: Vector3): void;
  19629. setTimeStep(timeStep: number): void;
  19630. getTimeStep(): number;
  19631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19632. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19635. removePhysicsBody(impostor: PhysicsImpostor): void;
  19636. generateJoint(joint: PhysicsImpostorJoint): void;
  19637. removeJoint(joint: PhysicsImpostorJoint): void;
  19638. isSupported(): boolean;
  19639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19646. getBodyMass(impostor: PhysicsImpostor): number;
  19647. getBodyFriction(impostor: PhysicsImpostor): number;
  19648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19649. getBodyRestitution(impostor: PhysicsImpostor): number;
  19650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19651. getBodyPressure?(impostor: PhysicsImpostor): number;
  19652. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19653. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19654. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19655. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19656. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19657. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19658. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19659. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19660. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19661. sleepBody(impostor: PhysicsImpostor): void;
  19662. wakeUpBody(impostor: PhysicsImpostor): void;
  19663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19664. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19665. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19666. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19667. getRadius(impostor: PhysicsImpostor): number;
  19668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19669. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19670. dispose(): void;
  19671. }
  19672. /**
  19673. * Interface used to define a physics engine
  19674. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19675. */
  19676. export interface IPhysicsEngine {
  19677. /**
  19678. * Gets the gravity vector used by the simulation
  19679. */
  19680. gravity: Vector3;
  19681. /**
  19682. * Sets the gravity vector used by the simulation
  19683. * @param gravity defines the gravity vector to use
  19684. */
  19685. setGravity(gravity: Vector3): void;
  19686. /**
  19687. * Set the time step of the physics engine.
  19688. * Default is 1/60.
  19689. * To slow it down, enter 1/600 for example.
  19690. * To speed it up, 1/30
  19691. * @param newTimeStep the new timestep to apply to this world.
  19692. */
  19693. setTimeStep(newTimeStep: number): void;
  19694. /**
  19695. * Get the time step of the physics engine.
  19696. * @returns the current time step
  19697. */
  19698. getTimeStep(): number;
  19699. /**
  19700. * Release all resources
  19701. */
  19702. dispose(): void;
  19703. /**
  19704. * Gets the name of the current physics plugin
  19705. * @returns the name of the plugin
  19706. */
  19707. getPhysicsPluginName(): string;
  19708. /**
  19709. * Adding a new impostor for the impostor tracking.
  19710. * This will be done by the impostor itself.
  19711. * @param impostor the impostor to add
  19712. */
  19713. addImpostor(impostor: PhysicsImpostor): void;
  19714. /**
  19715. * Remove an impostor from the engine.
  19716. * This impostor and its mesh will not longer be updated by the physics engine.
  19717. * @param impostor the impostor to remove
  19718. */
  19719. removeImpostor(impostor: PhysicsImpostor): void;
  19720. /**
  19721. * Add a joint to the physics engine
  19722. * @param mainImpostor defines the main impostor to which the joint is added.
  19723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19724. * @param joint defines the joint that will connect both impostors.
  19725. */
  19726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19727. /**
  19728. * Removes a joint from the simulation
  19729. * @param mainImpostor defines the impostor used with the joint
  19730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19731. * @param joint defines the joint to remove
  19732. */
  19733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19734. /**
  19735. * Gets the current plugin used to run the simulation
  19736. * @returns current plugin
  19737. */
  19738. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19739. /**
  19740. * Gets the list of physic impostors
  19741. * @returns an array of PhysicsImpostor
  19742. */
  19743. getImpostors(): Array<PhysicsImpostor>;
  19744. /**
  19745. * Gets the impostor for a physics enabled object
  19746. * @param object defines the object impersonated by the impostor
  19747. * @returns the PhysicsImpostor or null if not found
  19748. */
  19749. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19750. /**
  19751. * Gets the impostor for a physics body object
  19752. * @param body defines physics body used by the impostor
  19753. * @returns the PhysicsImpostor or null if not found
  19754. */
  19755. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19756. /**
  19757. * Does a raycast in the physics world
  19758. * @param from when should the ray start?
  19759. * @param to when should the ray end?
  19760. * @returns PhysicsRaycastResult
  19761. */
  19762. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19763. /**
  19764. * Called by the scene. No need to call it.
  19765. * @param delta defines the timespam between frames
  19766. */ private _step(delta: number): void;
  19767. }
  19768. }
  19769. declare module BABYLON {
  19770. /**
  19771. * The interface for the physics imposter parameters
  19772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19773. */
  19774. export interface PhysicsImpostorParameters {
  19775. /**
  19776. * The mass of the physics imposter
  19777. */
  19778. mass: number;
  19779. /**
  19780. * The friction of the physics imposter
  19781. */
  19782. friction?: number;
  19783. /**
  19784. * The coefficient of restitution of the physics imposter
  19785. */
  19786. restitution?: number;
  19787. /**
  19788. * The native options of the physics imposter
  19789. */
  19790. nativeOptions?: any;
  19791. /**
  19792. * Specifies if the parent should be ignored
  19793. */
  19794. ignoreParent?: boolean;
  19795. /**
  19796. * Specifies if bi-directional transformations should be disabled
  19797. */
  19798. disableBidirectionalTransformation?: boolean;
  19799. /**
  19800. * The pressure inside the physics imposter, soft object only
  19801. */
  19802. pressure?: number;
  19803. /**
  19804. * The stiffness the physics imposter, soft object only
  19805. */
  19806. stiffness?: number;
  19807. /**
  19808. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19809. */
  19810. velocityIterations?: number;
  19811. /**
  19812. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19813. */
  19814. positionIterations?: number;
  19815. /**
  19816. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19817. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19818. * Add to fix multiple points
  19819. */
  19820. fixedPoints?: number;
  19821. /**
  19822. * The collision margin around a soft object
  19823. */
  19824. margin?: number;
  19825. /**
  19826. * The collision margin around a soft object
  19827. */
  19828. damping?: number;
  19829. /**
  19830. * The path for a rope based on an extrusion
  19831. */
  19832. path?: any;
  19833. /**
  19834. * The shape of an extrusion used for a rope based on an extrusion
  19835. */
  19836. shape?: any;
  19837. }
  19838. /**
  19839. * Interface for a physics-enabled object
  19840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export interface IPhysicsEnabledObject {
  19843. /**
  19844. * The position of the physics-enabled object
  19845. */
  19846. position: Vector3;
  19847. /**
  19848. * The rotation of the physics-enabled object
  19849. */
  19850. rotationQuaternion: Nullable<Quaternion>;
  19851. /**
  19852. * The scale of the physics-enabled object
  19853. */
  19854. scaling: Vector3;
  19855. /**
  19856. * The rotation of the physics-enabled object
  19857. */
  19858. rotation?: Vector3;
  19859. /**
  19860. * The parent of the physics-enabled object
  19861. */
  19862. parent?: any;
  19863. /**
  19864. * The bounding info of the physics-enabled object
  19865. * @returns The bounding info of the physics-enabled object
  19866. */
  19867. getBoundingInfo(): BoundingInfo;
  19868. /**
  19869. * Computes the world matrix
  19870. * @param force Specifies if the world matrix should be computed by force
  19871. * @returns A world matrix
  19872. */
  19873. computeWorldMatrix(force: boolean): Matrix;
  19874. /**
  19875. * Gets the world matrix
  19876. * @returns A world matrix
  19877. */
  19878. getWorldMatrix?(): Matrix;
  19879. /**
  19880. * Gets the child meshes
  19881. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19882. * @returns An array of abstract meshes
  19883. */
  19884. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19885. /**
  19886. * Gets the vertex data
  19887. * @param kind The type of vertex data
  19888. * @returns A nullable array of numbers, or a float32 array
  19889. */
  19890. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19891. /**
  19892. * Gets the indices from the mesh
  19893. * @returns A nullable array of index arrays
  19894. */
  19895. getIndices?(): Nullable<IndicesArray>;
  19896. /**
  19897. * Gets the scene from the mesh
  19898. * @returns the indices array or null
  19899. */
  19900. getScene?(): Scene;
  19901. /**
  19902. * Gets the absolute position from the mesh
  19903. * @returns the absolute position
  19904. */
  19905. getAbsolutePosition(): Vector3;
  19906. /**
  19907. * Gets the absolute pivot point from the mesh
  19908. * @returns the absolute pivot point
  19909. */
  19910. getAbsolutePivotPoint(): Vector3;
  19911. /**
  19912. * Rotates the mesh
  19913. * @param axis The axis of rotation
  19914. * @param amount The amount of rotation
  19915. * @param space The space of the rotation
  19916. * @returns The rotation transform node
  19917. */
  19918. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19919. /**
  19920. * Translates the mesh
  19921. * @param axis The axis of translation
  19922. * @param distance The distance of translation
  19923. * @param space The space of the translation
  19924. * @returns The transform node
  19925. */
  19926. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19927. /**
  19928. * Sets the absolute position of the mesh
  19929. * @param absolutePosition The absolute position of the mesh
  19930. * @returns The transform node
  19931. */
  19932. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19933. /**
  19934. * Gets the class name of the mesh
  19935. * @returns The class name
  19936. */
  19937. getClassName(): string;
  19938. }
  19939. /**
  19940. * Represents a physics imposter
  19941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19942. */
  19943. export class PhysicsImpostor {
  19944. /**
  19945. * The physics-enabled object used as the physics imposter
  19946. */
  19947. object: IPhysicsEnabledObject;
  19948. /**
  19949. * The type of the physics imposter
  19950. */
  19951. type: number;
  19952. private _options;
  19953. private _scene?;
  19954. /**
  19955. * The default object size of the imposter
  19956. */
  19957. static DEFAULT_OBJECT_SIZE: Vector3;
  19958. /**
  19959. * The identity quaternion of the imposter
  19960. */
  19961. static IDENTITY_QUATERNION: Quaternion;
  19962. /** @hidden */ private _pluginData: any;
  19963. private _physicsEngine;
  19964. private _physicsBody;
  19965. private _bodyUpdateRequired;
  19966. private _onBeforePhysicsStepCallbacks;
  19967. private _onAfterPhysicsStepCallbacks;
  19968. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  19969. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19970. otherImpostors: Array<PhysicsImpostor>;
  19971. }>;
  19972. private _deltaPosition;
  19973. private _deltaRotation;
  19974. private _deltaRotationConjugated;
  19975. /** hidden */ private _isFromLine: boolean;
  19976. private _parent;
  19977. private _isDisposed;
  19978. private static _tmpVecs;
  19979. private static _tmpQuat;
  19980. /**
  19981. * Specifies if the physics imposter is disposed
  19982. */
  19983. readonly isDisposed: boolean;
  19984. /**
  19985. * Gets the mass of the physics imposter
  19986. */
  19987. mass: number;
  19988. /**
  19989. * Gets the coefficient of friction
  19990. */
  19991. /**
  19992. * Sets the coefficient of friction
  19993. */
  19994. friction: number;
  19995. /**
  19996. * Gets the coefficient of restitution
  19997. */
  19998. /**
  19999. * Sets the coefficient of restitution
  20000. */
  20001. restitution: number;
  20002. /**
  20003. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20004. */
  20005. /**
  20006. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20007. */
  20008. pressure: number;
  20009. /**
  20010. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20011. */
  20012. /**
  20013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20014. */
  20015. stiffness: number;
  20016. /**
  20017. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20018. */
  20019. /**
  20020. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20021. */
  20022. velocityIterations: number;
  20023. /**
  20024. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20025. */
  20026. /**
  20027. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20028. */
  20029. positionIterations: number;
  20030. /**
  20031. * The unique id of the physics imposter
  20032. * set by the physics engine when adding this impostor to the array
  20033. */
  20034. uniqueId: number;
  20035. /**
  20036. * @hidden
  20037. */
  20038. soft: boolean;
  20039. /**
  20040. * @hidden
  20041. */
  20042. segments: number;
  20043. private _joints;
  20044. /**
  20045. * Initializes the physics imposter
  20046. * @param object The physics-enabled object used as the physics imposter
  20047. * @param type The type of the physics imposter
  20048. * @param _options The options for the physics imposter
  20049. * @param _scene The Babylon scene
  20050. */
  20051. constructor(
  20052. /**
  20053. * The physics-enabled object used as the physics imposter
  20054. */
  20055. object: IPhysicsEnabledObject,
  20056. /**
  20057. * The type of the physics imposter
  20058. */
  20059. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20060. /**
  20061. * This function will completly initialize this impostor.
  20062. * It will create a new body - but only if this mesh has no parent.
  20063. * If it has, this impostor will not be used other than to define the impostor
  20064. * of the child mesh.
  20065. * @hidden
  20066. */ private _init(): void;
  20067. private _getPhysicsParent;
  20068. /**
  20069. * Should a new body be generated.
  20070. * @returns boolean specifying if body initialization is required
  20071. */
  20072. isBodyInitRequired(): boolean;
  20073. /**
  20074. * Sets the updated scaling
  20075. * @param updated Specifies if the scaling is updated
  20076. */
  20077. setScalingUpdated(): void;
  20078. /**
  20079. * Force a regeneration of this or the parent's impostor's body.
  20080. * Use under cautious - This will remove all joints already implemented.
  20081. */
  20082. forceUpdate(): void;
  20083. /**
  20084. * Gets the body that holds this impostor. Either its own, or its parent.
  20085. */
  20086. /**
  20087. * Set the physics body. Used mainly by the physics engine/plugin
  20088. */
  20089. physicsBody: any;
  20090. /**
  20091. * Get the parent of the physics imposter
  20092. * @returns Physics imposter or null
  20093. */
  20094. /**
  20095. * Sets the parent of the physics imposter
  20096. */
  20097. parent: Nullable<PhysicsImpostor>;
  20098. /**
  20099. * Resets the update flags
  20100. */
  20101. resetUpdateFlags(): void;
  20102. /**
  20103. * Gets the object extend size
  20104. * @returns the object extend size
  20105. */
  20106. getObjectExtendSize(): Vector3;
  20107. /**
  20108. * Gets the object center
  20109. * @returns The object center
  20110. */
  20111. getObjectCenter(): Vector3;
  20112. /**
  20113. * Get a specific parametes from the options parameter
  20114. * @param paramName The object parameter name
  20115. * @returns The object parameter
  20116. */
  20117. getParam(paramName: string): any;
  20118. /**
  20119. * Sets a specific parameter in the options given to the physics plugin
  20120. * @param paramName The parameter name
  20121. * @param value The value of the parameter
  20122. */
  20123. setParam(paramName: string, value: number): void;
  20124. /**
  20125. * Specifically change the body's mass option. Won't recreate the physics body object
  20126. * @param mass The mass of the physics imposter
  20127. */
  20128. setMass(mass: number): void;
  20129. /**
  20130. * Gets the linear velocity
  20131. * @returns linear velocity or null
  20132. */
  20133. getLinearVelocity(): Nullable<Vector3>;
  20134. /**
  20135. * Sets the linear velocity
  20136. * @param velocity linear velocity or null
  20137. */
  20138. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20139. /**
  20140. * Gets the angular velocity
  20141. * @returns angular velocity or null
  20142. */
  20143. getAngularVelocity(): Nullable<Vector3>;
  20144. /**
  20145. * Sets the angular velocity
  20146. * @param velocity The velocity or null
  20147. */
  20148. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20149. /**
  20150. * Execute a function with the physics plugin native code
  20151. * Provide a function the will have two variables - the world object and the physics body object
  20152. * @param func The function to execute with the physics plugin native code
  20153. */
  20154. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20155. /**
  20156. * Register a function that will be executed before the physics world is stepping forward
  20157. * @param func The function to execute before the physics world is stepped forward
  20158. */
  20159. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20160. /**
  20161. * Unregister a function that will be executed before the physics world is stepping forward
  20162. * @param func The function to execute before the physics world is stepped forward
  20163. */
  20164. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20165. /**
  20166. * Register a function that will be executed after the physics step
  20167. * @param func The function to execute after physics step
  20168. */
  20169. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20170. /**
  20171. * Unregisters a function that will be executed after the physics step
  20172. * @param func The function to execute after physics step
  20173. */
  20174. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20175. /**
  20176. * register a function that will be executed when this impostor collides against a different body
  20177. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20178. * @param func Callback that is executed on collision
  20179. */
  20180. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20181. /**
  20182. * Unregisters the physics imposter on contact
  20183. * @param collideAgainst The physics object to collide against
  20184. * @param func Callback to execute on collision
  20185. */
  20186. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20187. private _tmpQuat;
  20188. private _tmpQuat2;
  20189. /**
  20190. * Get the parent rotation
  20191. * @returns The parent rotation
  20192. */
  20193. getParentsRotation(): Quaternion;
  20194. /**
  20195. * this function is executed by the physics engine.
  20196. */
  20197. beforeStep: () => void;
  20198. /**
  20199. * this function is executed by the physics engine
  20200. */
  20201. afterStep: () => void;
  20202. /**
  20203. * Legacy collision detection event support
  20204. */
  20205. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20206. /**
  20207. * event and body object due to cannon's event-based architecture.
  20208. */
  20209. onCollide: (e: {
  20210. body: any;
  20211. }) => void;
  20212. /**
  20213. * Apply a force
  20214. * @param force The force to apply
  20215. * @param contactPoint The contact point for the force
  20216. * @returns The physics imposter
  20217. */
  20218. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20219. /**
  20220. * Apply an impulse
  20221. * @param force The impulse force
  20222. * @param contactPoint The contact point for the impulse force
  20223. * @returns The physics imposter
  20224. */
  20225. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20226. /**
  20227. * A help function to create a joint
  20228. * @param otherImpostor A physics imposter used to create a joint
  20229. * @param jointType The type of joint
  20230. * @param jointData The data for the joint
  20231. * @returns The physics imposter
  20232. */
  20233. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20234. /**
  20235. * Add a joint to this impostor with a different impostor
  20236. * @param otherImpostor A physics imposter used to add a joint
  20237. * @param joint The joint to add
  20238. * @returns The physics imposter
  20239. */
  20240. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20241. /**
  20242. * Add an anchor to a cloth impostor
  20243. * @param otherImpostor rigid impostor to anchor to
  20244. * @param width ratio across width from 0 to 1
  20245. * @param height ratio up height from 0 to 1
  20246. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20247. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20248. * @returns impostor the soft imposter
  20249. */
  20250. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20251. /**
  20252. * Add a hook to a rope impostor
  20253. * @param otherImpostor rigid impostor to anchor to
  20254. * @param length ratio across rope from 0 to 1
  20255. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20256. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20257. * @returns impostor the rope imposter
  20258. */
  20259. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20260. /**
  20261. * Will keep this body still, in a sleep mode.
  20262. * @returns the physics imposter
  20263. */
  20264. sleep(): PhysicsImpostor;
  20265. /**
  20266. * Wake the body up.
  20267. * @returns The physics imposter
  20268. */
  20269. wakeUp(): PhysicsImpostor;
  20270. /**
  20271. * Clones the physics imposter
  20272. * @param newObject The physics imposter clones to this physics-enabled object
  20273. * @returns A nullable physics imposter
  20274. */
  20275. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20276. /**
  20277. * Disposes the physics imposter
  20278. */
  20279. dispose(): void;
  20280. /**
  20281. * Sets the delta position
  20282. * @param position The delta position amount
  20283. */
  20284. setDeltaPosition(position: Vector3): void;
  20285. /**
  20286. * Sets the delta rotation
  20287. * @param rotation The delta rotation amount
  20288. */
  20289. setDeltaRotation(rotation: Quaternion): void;
  20290. /**
  20291. * Gets the box size of the physics imposter and stores the result in the input parameter
  20292. * @param result Stores the box size
  20293. * @returns The physics imposter
  20294. */
  20295. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20296. /**
  20297. * Gets the radius of the physics imposter
  20298. * @returns Radius of the physics imposter
  20299. */
  20300. getRadius(): number;
  20301. /**
  20302. * Sync a bone with this impostor
  20303. * @param bone The bone to sync to the impostor.
  20304. * @param boneMesh The mesh that the bone is influencing.
  20305. * @param jointPivot The pivot of the joint / bone in local space.
  20306. * @param distToJoint Optional distance from the impostor to the joint.
  20307. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20308. */
  20309. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20310. /**
  20311. * Sync impostor to a bone
  20312. * @param bone The bone that the impostor will be synced to.
  20313. * @param boneMesh The mesh that the bone is influencing.
  20314. * @param jointPivot The pivot of the joint / bone in local space.
  20315. * @param distToJoint Optional distance from the impostor to the joint.
  20316. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20317. * @param boneAxis Optional vector3 axis the bone is aligned with
  20318. */
  20319. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20320. /**
  20321. * No-Imposter type
  20322. */
  20323. static NoImpostor: number;
  20324. /**
  20325. * Sphere-Imposter type
  20326. */
  20327. static SphereImpostor: number;
  20328. /**
  20329. * Box-Imposter type
  20330. */
  20331. static BoxImpostor: number;
  20332. /**
  20333. * Plane-Imposter type
  20334. */
  20335. static PlaneImpostor: number;
  20336. /**
  20337. * Mesh-imposter type
  20338. */
  20339. static MeshImpostor: number;
  20340. /**
  20341. * Cylinder-Imposter type
  20342. */
  20343. static CylinderImpostor: number;
  20344. /**
  20345. * Particle-Imposter type
  20346. */
  20347. static ParticleImpostor: number;
  20348. /**
  20349. * Heightmap-Imposter type
  20350. */
  20351. static HeightmapImpostor: number;
  20352. /**
  20353. * ConvexHull-Impostor type (Ammo.js plugin only)
  20354. */
  20355. static ConvexHullImpostor: number;
  20356. /**
  20357. * Rope-Imposter type
  20358. */
  20359. static RopeImpostor: number;
  20360. /**
  20361. * Cloth-Imposter type
  20362. */
  20363. static ClothImpostor: number;
  20364. /**
  20365. * Softbody-Imposter type
  20366. */
  20367. static SoftbodyImpostor: number;
  20368. }
  20369. }
  20370. declare module BABYLON {
  20371. /**
  20372. * @hidden
  20373. **/
  20374. export class _CreationDataStorage {
  20375. closePath?: boolean;
  20376. closeArray?: boolean;
  20377. idx: number[];
  20378. dashSize: number;
  20379. gapSize: number;
  20380. path3D: Path3D;
  20381. pathArray: Vector3[][];
  20382. arc: number;
  20383. radius: number;
  20384. cap: number;
  20385. tessellation: number;
  20386. }
  20387. /**
  20388. * @hidden
  20389. **/ private class _InstanceDataStorage {
  20390. visibleInstances: any;
  20391. batchCache: _InstancesBatch;
  20392. instancesBufferSize: number;
  20393. instancesBuffer: Nullable<Buffer>;
  20394. instancesData: Float32Array;
  20395. overridenInstanceCount: number;
  20396. isFrozen: boolean;
  20397. previousBatch: _InstancesBatch;
  20398. hardwareInstancedRendering: boolean;
  20399. sideOrientation: number;
  20400. }
  20401. /**
  20402. * @hidden
  20403. **/
  20404. export class _InstancesBatch {
  20405. mustReturn: boolean;
  20406. visibleInstances: Nullable<InstancedMesh[]>[];
  20407. renderSelf: boolean[];
  20408. hardwareInstancedRendering: boolean[];
  20409. }
  20410. /**
  20411. * Class used to represent renderable models
  20412. */
  20413. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20414. /**
  20415. * Mesh side orientation : usually the external or front surface
  20416. */
  20417. static readonly FRONTSIDE: number;
  20418. /**
  20419. * Mesh side orientation : usually the internal or back surface
  20420. */
  20421. static readonly BACKSIDE: number;
  20422. /**
  20423. * Mesh side orientation : both internal and external or front and back surfaces
  20424. */
  20425. static readonly DOUBLESIDE: number;
  20426. /**
  20427. * Mesh side orientation : by default, `FRONTSIDE`
  20428. */
  20429. static readonly DEFAULTSIDE: number;
  20430. /**
  20431. * Mesh cap setting : no cap
  20432. */
  20433. static readonly NO_CAP: number;
  20434. /**
  20435. * Mesh cap setting : one cap at the beginning of the mesh
  20436. */
  20437. static readonly CAP_START: number;
  20438. /**
  20439. * Mesh cap setting : one cap at the end of the mesh
  20440. */
  20441. static readonly CAP_END: number;
  20442. /**
  20443. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20444. */
  20445. static readonly CAP_ALL: number;
  20446. /**
  20447. * Mesh pattern setting : no flip or rotate
  20448. */
  20449. static readonly NO_FLIP: number;
  20450. /**
  20451. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20452. */
  20453. static readonly FLIP_TILE: number;
  20454. /**
  20455. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20456. */
  20457. static readonly ROTATE_TILE: number;
  20458. /**
  20459. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20460. */
  20461. static readonly FLIP_ROW: number;
  20462. /**
  20463. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20464. */
  20465. static readonly ROTATE_ROW: number;
  20466. /**
  20467. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20468. */
  20469. static readonly FLIP_N_ROTATE_TILE: number;
  20470. /**
  20471. * Mesh pattern setting : rotate pattern and rotate
  20472. */
  20473. static readonly FLIP_N_ROTATE_ROW: number;
  20474. /**
  20475. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20476. */
  20477. static readonly CENTER: number;
  20478. /**
  20479. * Mesh tile positioning : part tiles on left
  20480. */
  20481. static readonly LEFT: number;
  20482. /**
  20483. * Mesh tile positioning : part tiles on right
  20484. */
  20485. static readonly RIGHT: number;
  20486. /**
  20487. * Mesh tile positioning : part tiles on top
  20488. */
  20489. static readonly TOP: number;
  20490. /**
  20491. * Mesh tile positioning : part tiles on bottom
  20492. */
  20493. static readonly BOTTOM: number;
  20494. /**
  20495. * Gets the default side orientation.
  20496. * @param orientation the orientation to value to attempt to get
  20497. * @returns the default orientation
  20498. * @hidden
  20499. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20500. private _internalMeshDataInfo;
  20501. /**
  20502. * An event triggered before rendering the mesh
  20503. */
  20504. readonly onBeforeRenderObservable: Observable<Mesh>;
  20505. /**
  20506. * An event triggered before binding the mesh
  20507. */
  20508. readonly onBeforeBindObservable: Observable<Mesh>;
  20509. /**
  20510. * An event triggered after rendering the mesh
  20511. */
  20512. readonly onAfterRenderObservable: Observable<Mesh>;
  20513. /**
  20514. * An event triggered before drawing the mesh
  20515. */
  20516. readonly onBeforeDrawObservable: Observable<Mesh>;
  20517. private _onBeforeDrawObserver;
  20518. /**
  20519. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20520. */
  20521. onBeforeDraw: () => void;
  20522. /**
  20523. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20524. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20525. */
  20526. delayLoadState: number;
  20527. /**
  20528. * Gets the list of instances created from this mesh
  20529. * it is not supposed to be modified manually.
  20530. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20531. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20532. */
  20533. instances: InstancedMesh[];
  20534. /**
  20535. * Gets the file containing delay loading data for this mesh
  20536. */
  20537. delayLoadingFile: string;
  20538. /** @hidden */ private _binaryInfo: any;
  20539. /**
  20540. * User defined function used to change how LOD level selection is done
  20541. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20542. */
  20543. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20544. /**
  20545. * Gets or sets the morph target manager
  20546. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20547. */
  20548. morphTargetManager: Nullable<MorphTargetManager>;
  20549. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  20550. /** @hidden */ private _geometry: Nullable<Geometry>;
  20551. /** @hidden */ private _delayInfo: Array<string>;
  20552. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20553. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  20554. private _effectiveMaterial;
  20555. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  20556. /** @hidden */ private _originalBuilderSideOrientation: number;
  20557. /**
  20558. * Use this property to change the original side orientation defined at construction time
  20559. */
  20560. overrideMaterialSideOrientation: Nullable<number>;
  20561. /**
  20562. * Gets the source mesh (the one used to clone this one from)
  20563. */
  20564. readonly source: Nullable<Mesh>;
  20565. /**
  20566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20567. */
  20568. isUnIndexed: boolean;
  20569. /**
  20570. * @constructor
  20571. * @param name The value used by scene.getMeshByName() to do a lookup.
  20572. * @param scene The scene to add this mesh to.
  20573. * @param parent The parent of this mesh, if it has one
  20574. * @param source An optional Mesh from which geometry is shared, cloned.
  20575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20576. * When false, achieved by calling a clone(), also passing False.
  20577. * This will make creation of children, recursive.
  20578. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20579. */
  20580. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20581. /**
  20582. * Gets the class name
  20583. * @returns the string "Mesh".
  20584. */
  20585. getClassName(): string;
  20586. /** @hidden */ protected readonly _isMesh: boolean;
  20587. /**
  20588. * Returns a description of this mesh
  20589. * @param fullDetails define if full details about this mesh must be used
  20590. * @returns a descriptive string representing this mesh
  20591. */
  20592. toString(fullDetails?: boolean): string;
  20593. /** @hidden */ private _unBindEffect(): void;
  20594. /**
  20595. * Gets a boolean indicating if this mesh has LOD
  20596. */
  20597. readonly hasLODLevels: boolean;
  20598. /**
  20599. * Gets the list of MeshLODLevel associated with the current mesh
  20600. * @returns an array of MeshLODLevel
  20601. */
  20602. getLODLevels(): MeshLODLevel[];
  20603. private _sortLODLevels;
  20604. /**
  20605. * Add a mesh as LOD level triggered at the given distance.
  20606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20607. * @param distance The distance from the center of the object to show this level
  20608. * @param mesh The mesh to be added as LOD level (can be null)
  20609. * @return This mesh (for chaining)
  20610. */
  20611. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20612. /**
  20613. * Returns the LOD level mesh at the passed distance or null if not found.
  20614. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20615. * @param distance The distance from the center of the object to show this level
  20616. * @returns a Mesh or `null`
  20617. */
  20618. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20619. /**
  20620. * Remove a mesh from the LOD array
  20621. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20622. * @param mesh defines the mesh to be removed
  20623. * @return This mesh (for chaining)
  20624. */
  20625. removeLODLevel(mesh: Mesh): Mesh;
  20626. /**
  20627. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20628. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20629. * @param camera defines the camera to use to compute distance
  20630. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20631. * @return This mesh (for chaining)
  20632. */
  20633. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20634. /**
  20635. * Gets the mesh internal Geometry object
  20636. */
  20637. readonly geometry: Nullable<Geometry>;
  20638. /**
  20639. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20640. * @returns the total number of vertices
  20641. */
  20642. getTotalVertices(): number;
  20643. /**
  20644. * Returns the content of an associated vertex buffer
  20645. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20646. * - VertexBuffer.PositionKind
  20647. * - VertexBuffer.UVKind
  20648. * - VertexBuffer.UV2Kind
  20649. * - VertexBuffer.UV3Kind
  20650. * - VertexBuffer.UV4Kind
  20651. * - VertexBuffer.UV5Kind
  20652. * - VertexBuffer.UV6Kind
  20653. * - VertexBuffer.ColorKind
  20654. * - VertexBuffer.MatricesIndicesKind
  20655. * - VertexBuffer.MatricesIndicesExtraKind
  20656. * - VertexBuffer.MatricesWeightsKind
  20657. * - VertexBuffer.MatricesWeightsExtraKind
  20658. * @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
  20659. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20660. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20661. */
  20662. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20663. /**
  20664. * Returns the mesh VertexBuffer object from the requested `kind`
  20665. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20666. * - VertexBuffer.PositionKind
  20667. * - VertexBuffer.NormalKind
  20668. * - VertexBuffer.UVKind
  20669. * - VertexBuffer.UV2Kind
  20670. * - VertexBuffer.UV3Kind
  20671. * - VertexBuffer.UV4Kind
  20672. * - VertexBuffer.UV5Kind
  20673. * - VertexBuffer.UV6Kind
  20674. * - VertexBuffer.ColorKind
  20675. * - VertexBuffer.MatricesIndicesKind
  20676. * - VertexBuffer.MatricesIndicesExtraKind
  20677. * - VertexBuffer.MatricesWeightsKind
  20678. * - VertexBuffer.MatricesWeightsExtraKind
  20679. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20680. */
  20681. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20682. /**
  20683. * Tests if a specific vertex buffer is associated with this mesh
  20684. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20685. * - VertexBuffer.PositionKind
  20686. * - VertexBuffer.NormalKind
  20687. * - VertexBuffer.UVKind
  20688. * - VertexBuffer.UV2Kind
  20689. * - VertexBuffer.UV3Kind
  20690. * - VertexBuffer.UV4Kind
  20691. * - VertexBuffer.UV5Kind
  20692. * - VertexBuffer.UV6Kind
  20693. * - VertexBuffer.ColorKind
  20694. * - VertexBuffer.MatricesIndicesKind
  20695. * - VertexBuffer.MatricesIndicesExtraKind
  20696. * - VertexBuffer.MatricesWeightsKind
  20697. * - VertexBuffer.MatricesWeightsExtraKind
  20698. * @returns a boolean
  20699. */
  20700. isVerticesDataPresent(kind: string): boolean;
  20701. /**
  20702. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20703. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20704. * - VertexBuffer.PositionKind
  20705. * - VertexBuffer.UVKind
  20706. * - VertexBuffer.UV2Kind
  20707. * - VertexBuffer.UV3Kind
  20708. * - VertexBuffer.UV4Kind
  20709. * - VertexBuffer.UV5Kind
  20710. * - VertexBuffer.UV6Kind
  20711. * - VertexBuffer.ColorKind
  20712. * - VertexBuffer.MatricesIndicesKind
  20713. * - VertexBuffer.MatricesIndicesExtraKind
  20714. * - VertexBuffer.MatricesWeightsKind
  20715. * - VertexBuffer.MatricesWeightsExtraKind
  20716. * @returns a boolean
  20717. */
  20718. isVertexBufferUpdatable(kind: string): boolean;
  20719. /**
  20720. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.NormalKind
  20724. * - VertexBuffer.UVKind
  20725. * - VertexBuffer.UV2Kind
  20726. * - VertexBuffer.UV3Kind
  20727. * - VertexBuffer.UV4Kind
  20728. * - VertexBuffer.UV5Kind
  20729. * - VertexBuffer.UV6Kind
  20730. * - VertexBuffer.ColorKind
  20731. * - VertexBuffer.MatricesIndicesKind
  20732. * - VertexBuffer.MatricesIndicesExtraKind
  20733. * - VertexBuffer.MatricesWeightsKind
  20734. * - VertexBuffer.MatricesWeightsExtraKind
  20735. * @returns an array of strings
  20736. */
  20737. getVerticesDataKinds(): string[];
  20738. /**
  20739. * Returns a positive integer : the total number of indices in this mesh geometry.
  20740. * @returns the numner of indices or zero if the mesh has no geometry.
  20741. */
  20742. getTotalIndices(): number;
  20743. /**
  20744. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20745. * @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.
  20746. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20747. * @returns the indices array or an empty array if the mesh has no geometry
  20748. */
  20749. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20750. readonly isBlocked: boolean;
  20751. /**
  20752. * Determine if the current mesh is ready to be rendered
  20753. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20754. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20755. * @returns true if all associated assets are ready (material, textures, shaders)
  20756. */
  20757. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20758. /**
  20759. * 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.
  20760. */
  20761. readonly areNormalsFrozen: boolean;
  20762. /**
  20763. * 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.
  20764. * @returns the current mesh
  20765. */
  20766. freezeNormals(): Mesh;
  20767. /**
  20768. * 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
  20769. * @returns the current mesh
  20770. */
  20771. unfreezeNormals(): Mesh;
  20772. /**
  20773. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20774. */
  20775. overridenInstanceCount: number;
  20776. /** @hidden */ private _preActivate(): Mesh;
  20777. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  20778. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20779. /**
  20780. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20781. * This means the mesh underlying bounding box and sphere are recomputed.
  20782. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20783. * @returns the current mesh
  20784. */
  20785. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20786. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20787. /**
  20788. * This function will subdivide the mesh into multiple submeshes
  20789. * @param count defines the expected number of submeshes
  20790. */
  20791. subdivide(count: number): void;
  20792. /**
  20793. * Copy a FloatArray into a specific associated vertex buffer
  20794. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20795. * - VertexBuffer.PositionKind
  20796. * - VertexBuffer.UVKind
  20797. * - VertexBuffer.UV2Kind
  20798. * - VertexBuffer.UV3Kind
  20799. * - VertexBuffer.UV4Kind
  20800. * - VertexBuffer.UV5Kind
  20801. * - VertexBuffer.UV6Kind
  20802. * - VertexBuffer.ColorKind
  20803. * - VertexBuffer.MatricesIndicesKind
  20804. * - VertexBuffer.MatricesIndicesExtraKind
  20805. * - VertexBuffer.MatricesWeightsKind
  20806. * - VertexBuffer.MatricesWeightsExtraKind
  20807. * @param data defines the data source
  20808. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20809. * @param stride defines the data stride size (can be null)
  20810. * @returns the current mesh
  20811. */
  20812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20813. /**
  20814. * Flags an associated vertex buffer as updatable
  20815. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20816. * - VertexBuffer.PositionKind
  20817. * - VertexBuffer.UVKind
  20818. * - VertexBuffer.UV2Kind
  20819. * - VertexBuffer.UV3Kind
  20820. * - VertexBuffer.UV4Kind
  20821. * - VertexBuffer.UV5Kind
  20822. * - VertexBuffer.UV6Kind
  20823. * - VertexBuffer.ColorKind
  20824. * - VertexBuffer.MatricesIndicesKind
  20825. * - VertexBuffer.MatricesIndicesExtraKind
  20826. * - VertexBuffer.MatricesWeightsKind
  20827. * - VertexBuffer.MatricesWeightsExtraKind
  20828. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20829. */
  20830. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20831. /**
  20832. * Sets the mesh global Vertex Buffer
  20833. * @param buffer defines the buffer to use
  20834. * @returns the current mesh
  20835. */
  20836. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20837. /**
  20838. * Update a specific associated vertex buffer
  20839. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20840. * - VertexBuffer.PositionKind
  20841. * - VertexBuffer.UVKind
  20842. * - VertexBuffer.UV2Kind
  20843. * - VertexBuffer.UV3Kind
  20844. * - VertexBuffer.UV4Kind
  20845. * - VertexBuffer.UV5Kind
  20846. * - VertexBuffer.UV6Kind
  20847. * - VertexBuffer.ColorKind
  20848. * - VertexBuffer.MatricesIndicesKind
  20849. * - VertexBuffer.MatricesIndicesExtraKind
  20850. * - VertexBuffer.MatricesWeightsKind
  20851. * - VertexBuffer.MatricesWeightsExtraKind
  20852. * @param data defines the data source
  20853. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20854. * @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)
  20855. * @returns the current mesh
  20856. */
  20857. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20858. /**
  20859. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20860. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20861. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20862. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20863. * @returns the current mesh
  20864. */
  20865. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20866. /**
  20867. * Creates a un-shared specific occurence of the geometry for the mesh.
  20868. * @returns the current mesh
  20869. */
  20870. makeGeometryUnique(): Mesh;
  20871. /**
  20872. * Set the index buffer of this mesh
  20873. * @param indices defines the source data
  20874. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20875. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20876. * @returns the current mesh
  20877. */
  20878. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20879. /**
  20880. * Update the current index buffer
  20881. * @param indices defines the source data
  20882. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20883. * @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)
  20884. * @returns the current mesh
  20885. */
  20886. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20887. /**
  20888. * Invert the geometry to move from a right handed system to a left handed one.
  20889. * @returns the current mesh
  20890. */
  20891. toLeftHanded(): Mesh;
  20892. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20893. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20894. /**
  20895. * Registers for this mesh a javascript function called just before the rendering process
  20896. * @param func defines the function to call before rendering this mesh
  20897. * @returns the current mesh
  20898. */
  20899. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20900. /**
  20901. * Disposes a previously registered javascript function called before the rendering
  20902. * @param func defines the function to remove
  20903. * @returns the current mesh
  20904. */
  20905. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20906. /**
  20907. * Registers for this mesh a javascript function called just after the rendering is complete
  20908. * @param func defines the function to call after rendering this mesh
  20909. * @returns the current mesh
  20910. */
  20911. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20912. /**
  20913. * Disposes a previously registered javascript function called after the rendering.
  20914. * @param func defines the function to remove
  20915. * @returns the current mesh
  20916. */
  20917. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20918. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20919. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20920. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20921. /** @hidden */ private _freeze(): void;
  20922. /** @hidden */ private _unFreeze(): void;
  20923. /**
  20924. * 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
  20925. * @param subMesh defines the subMesh to render
  20926. * @param enableAlphaMode defines if alpha mode can be changed
  20927. * @returns the current mesh
  20928. */
  20929. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20930. private _onBeforeDraw;
  20931. /**
  20932. * Renormalize the mesh and patch it up if there are no weights
  20933. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20934. * However in the case of zero weights then we set just a single influence to 1.
  20935. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20936. */
  20937. cleanMatrixWeights(): void;
  20938. private normalizeSkinFourWeights;
  20939. private normalizeSkinWeightsAndExtra;
  20940. /**
  20941. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20942. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20943. * the user know there was an issue with importing the mesh
  20944. * @returns a validation object with skinned, valid and report string
  20945. */
  20946. validateSkinning(): {
  20947. skinned: boolean;
  20948. valid: boolean;
  20949. report: string;
  20950. };
  20951. /** @hidden */ private _checkDelayState(): Mesh;
  20952. private _queueLoad;
  20953. /**
  20954. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20955. * A mesh is in the frustum if its bounding box intersects the frustum
  20956. * @param frustumPlanes defines the frustum to test
  20957. * @returns true if the mesh is in the frustum planes
  20958. */
  20959. isInFrustum(frustumPlanes: Plane[]): boolean;
  20960. /**
  20961. * Sets the mesh material by the material or multiMaterial `id` property
  20962. * @param id is a string identifying the material or the multiMaterial
  20963. * @returns the current mesh
  20964. */
  20965. setMaterialByID(id: string): Mesh;
  20966. /**
  20967. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20968. * @returns an array of IAnimatable
  20969. */
  20970. getAnimatables(): IAnimatable[];
  20971. /**
  20972. * Modifies the mesh geometry according to the passed transformation matrix.
  20973. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20974. * The mesh normals are modified using the same transformation.
  20975. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20976. * @param transform defines the transform matrix to use
  20977. * @see http://doc.babylonjs.com/resources/baking_transformations
  20978. * @returns the current mesh
  20979. */
  20980. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20981. /**
  20982. * Modifies the mesh geometry according to its own current World Matrix.
  20983. * The mesh World Matrix is then reset.
  20984. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20985. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20986. * @see http://doc.babylonjs.com/resources/baking_transformations
  20987. * @returns the current mesh
  20988. */
  20989. bakeCurrentTransformIntoVertices(): Mesh;
  20990. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20991. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  20992. /** @hidden */ private _generatePointsArray(): boolean;
  20993. /**
  20994. * Returns a new Mesh object generated from the current mesh properties.
  20995. * This method must not get confused with createInstance()
  20996. * @param name is a string, the name given to the new mesh
  20997. * @param newParent can be any Node object (default `null`)
  20998. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20999. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21000. * @returns a new mesh
  21001. */
  21002. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21003. /**
  21004. * Releases resources associated with this mesh.
  21005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21007. */
  21008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21009. /**
  21010. * Modifies the mesh geometry according to a displacement map.
  21011. * 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.
  21012. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21013. * @param url is a string, the URL from the image file is to be downloaded.
  21014. * @param minHeight is the lower limit of the displacement.
  21015. * @param maxHeight is the upper limit of the displacement.
  21016. * @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.
  21017. * @param uvOffset is an optional vector2 used to offset UV.
  21018. * @param uvScale is an optional vector2 used to scale UV.
  21019. * @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.
  21020. * @returns the Mesh.
  21021. */
  21022. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21023. /**
  21024. * Modifies the mesh geometry according to a displacementMap buffer.
  21025. * 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.
  21026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21027. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21028. * @param heightMapWidth is the width of the buffer image.
  21029. * @param heightMapHeight is the height of the buffer image.
  21030. * @param minHeight is the lower limit of the displacement.
  21031. * @param maxHeight is the upper limit of the displacement.
  21032. * @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.
  21033. * @param uvOffset is an optional vector2 used to offset UV.
  21034. * @param uvScale is an optional vector2 used to scale UV.
  21035. * @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.
  21036. * @returns the Mesh.
  21037. */
  21038. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21039. /**
  21040. * Modify the mesh to get a flat shading rendering.
  21041. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21042. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21043. * @returns current mesh
  21044. */
  21045. convertToFlatShadedMesh(): Mesh;
  21046. /**
  21047. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21048. * In other words, more vertices, no more indices and a single bigger VBO.
  21049. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21050. * @returns current mesh
  21051. */
  21052. convertToUnIndexedMesh(): Mesh;
  21053. /**
  21054. * Inverses facet orientations.
  21055. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21056. * @param flipNormals will also inverts the normals
  21057. * @returns current mesh
  21058. */
  21059. flipFaces(flipNormals?: boolean): Mesh;
  21060. /**
  21061. * Increase the number of facets and hence vertices in a mesh
  21062. * Vertex normals are interpolated from existing vertex normals
  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. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21065. */
  21066. increaseVertices(numberPerEdge: number): void;
  21067. /**
  21068. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21069. * This will undo any application of covertToFlatShadedMesh
  21070. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21071. */
  21072. forceSharedVertices(): void;
  21073. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21074. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21075. /**
  21076. * Creates a new InstancedMesh object from the mesh model.
  21077. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21078. * @param name defines the name of the new instance
  21079. * @returns a new InstancedMesh
  21080. */
  21081. createInstance(name: string): InstancedMesh;
  21082. /**
  21083. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21084. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21085. * @returns the current mesh
  21086. */
  21087. synchronizeInstances(): Mesh;
  21088. /**
  21089. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21090. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21091. * This should be used together with the simplification to avoid disappearing triangles.
  21092. * @param successCallback an optional success callback to be called after the optimization finished.
  21093. * @returns the current mesh
  21094. */
  21095. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21096. /**
  21097. * Serialize current mesh
  21098. * @param serializationObject defines the object which will receive the serialization data
  21099. */
  21100. serialize(serializationObject: any): void;
  21101. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  21102. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21103. /**
  21104. * Returns a new Mesh object parsed from the source provided.
  21105. * @param parsedMesh is the source
  21106. * @param scene defines the hosting scene
  21107. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21108. * @returns a new Mesh
  21109. */
  21110. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21111. /**
  21112. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21113. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21114. * @param name defines the name of the mesh to create
  21115. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21116. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21117. * @param closePath creates a seam between the first and the last points of each path of the path array
  21118. * @param offset is taken in account only if the `pathArray` is containing a single path
  21119. * @param scene defines the hosting scene
  21120. * @param updatable defines if the mesh must be flagged as updatable
  21121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21122. * @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)
  21123. * @returns a new Mesh
  21124. */
  21125. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21126. /**
  21127. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21128. * @param name defines the name of the mesh to create
  21129. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21130. * @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
  21131. * @param scene defines the hosting scene
  21132. * @param updatable defines if the mesh must be flagged as updatable
  21133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21134. * @returns a new Mesh
  21135. */
  21136. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21137. /**
  21138. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21139. * @param name defines the name of the mesh to create
  21140. * @param size sets the size (float) of each box side (default 1)
  21141. * @param scene defines the hosting scene
  21142. * @param updatable defines if the mesh must be flagged as updatable
  21143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21144. * @returns a new Mesh
  21145. */
  21146. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21147. /**
  21148. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21149. * @param name defines the name of the mesh to create
  21150. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21151. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21152. * @param scene defines the hosting scene
  21153. * @param updatable defines if the mesh must be flagged as updatable
  21154. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21155. * @returns a new Mesh
  21156. */
  21157. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21158. /**
  21159. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21160. * @param name defines the name of the mesh to create
  21161. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21162. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21163. * @param scene defines the hosting scene
  21164. * @returns a new Mesh
  21165. */
  21166. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21167. /**
  21168. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21169. * @param name defines the name of the mesh to create
  21170. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21171. * @param diameterTop set the top cap diameter (floats, default 1)
  21172. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21173. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21174. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21175. * @param scene defines the hosting scene
  21176. * @param updatable defines if the mesh must be flagged as updatable
  21177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21178. * @returns a new Mesh
  21179. */
  21180. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21181. /**
  21182. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21183. * @param name defines the name of the mesh to create
  21184. * @param diameter sets the diameter size (float) of the torus (default 1)
  21185. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21186. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21187. * @param scene defines the hosting scene
  21188. * @param updatable defines if the mesh must be flagged as updatable
  21189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21190. * @returns a new Mesh
  21191. */
  21192. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21193. /**
  21194. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21195. * @param name defines the name of the mesh to create
  21196. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21197. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21198. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21199. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21200. * @param p the number of windings on X axis (positive integers, default 2)
  21201. * @param q the number of windings on Y axis (positive integers, default 3)
  21202. * @param scene defines the hosting scene
  21203. * @param updatable defines if the mesh must be flagged as updatable
  21204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21205. * @returns a new Mesh
  21206. */
  21207. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21208. /**
  21209. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21210. * @param name defines the name of the mesh to create
  21211. * @param points is an array successive Vector3
  21212. * @param scene defines the hosting scene
  21213. * @param updatable defines if the mesh must be flagged as updatable
  21214. * @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).
  21215. * @returns a new Mesh
  21216. */
  21217. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21218. /**
  21219. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21220. * @param name defines the name of the mesh to create
  21221. * @param points is an array successive Vector3
  21222. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21223. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21224. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21225. * @param scene defines the hosting scene
  21226. * @param updatable defines if the mesh must be flagged as updatable
  21227. * @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)
  21228. * @returns a new Mesh
  21229. */
  21230. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21231. /**
  21232. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21233. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21234. * 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.
  21235. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21236. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21237. * Remember you can only change the shape positions, not their number when updating a polygon.
  21238. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21239. * @param name defines the name of the mesh to create
  21240. * @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
  21241. * @param scene defines the hosting scene
  21242. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21243. * @param updatable defines if the mesh must be flagged as updatable
  21244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21245. * @param earcutInjection can be used to inject your own earcut reference
  21246. * @returns a new Mesh
  21247. */
  21248. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21249. /**
  21250. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21251. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21252. * @param name defines the name of the mesh to create
  21253. * @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
  21254. * @param depth defines the height of extrusion
  21255. * @param scene defines the hosting scene
  21256. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21257. * @param updatable defines if the mesh must be flagged as updatable
  21258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21259. * @param earcutInjection can be used to inject your own earcut reference
  21260. * @returns a new Mesh
  21261. */
  21262. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21263. /**
  21264. * Creates an extruded shape mesh.
  21265. * 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
  21266. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21267. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21268. * @param name defines the name of the mesh to create
  21269. * @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
  21270. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21271. * @param scale is the value to scale the shape
  21272. * @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
  21273. * @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
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21277. * @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)
  21278. * @returns a new Mesh
  21279. */
  21280. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21281. /**
  21282. * Creates an custom extruded shape mesh.
  21283. * The custom extrusion is a parametric shape.
  21284. * It has no predefined shape. Its final shape will depend on the input parameters.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21287. * @param name defines the name of the mesh to create
  21288. * @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
  21289. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21290. * @param scaleFunction is a custom Javascript function called on each path point
  21291. * @param rotationFunction is a custom Javascript function called on each path point
  21292. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21293. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21294. * @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
  21295. * @param scene defines the hosting scene
  21296. * @param updatable defines if the mesh must be flagged as updatable
  21297. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21298. * @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)
  21299. * @returns a new Mesh
  21300. */
  21301. 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;
  21302. /**
  21303. * Creates lathe mesh.
  21304. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21305. * Please consider using the same method from the MeshBuilder class instead
  21306. * @param name defines the name of the mesh to create
  21307. * @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
  21308. * @param radius is the radius value of the lathe
  21309. * @param tessellation is the side number of the lathe.
  21310. * @param scene defines the hosting scene
  21311. * @param updatable defines if the mesh must be flagged as updatable
  21312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21313. * @returns a new Mesh
  21314. */
  21315. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21316. /**
  21317. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21318. * @param name defines the name of the mesh to create
  21319. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21320. * @param scene defines the hosting scene
  21321. * @param updatable defines if the mesh must be flagged as updatable
  21322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21323. * @returns a new Mesh
  21324. */
  21325. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21326. /**
  21327. * Creates a ground mesh.
  21328. * Please consider using the same method from the MeshBuilder class instead
  21329. * @param name defines the name of the mesh to create
  21330. * @param width set the width of the ground
  21331. * @param height set the height of the ground
  21332. * @param subdivisions sets the number of subdivisions per side
  21333. * @param scene defines the hosting scene
  21334. * @param updatable defines if the mesh must be flagged as updatable
  21335. * @returns a new Mesh
  21336. */
  21337. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21338. /**
  21339. * Creates a tiled ground mesh.
  21340. * Please consider using the same method from the MeshBuilder class instead
  21341. * @param name defines the name of the mesh to create
  21342. * @param xmin set the ground minimum X coordinate
  21343. * @param zmin set the ground minimum Y coordinate
  21344. * @param xmax set the ground maximum X coordinate
  21345. * @param zmax set the ground maximum Z coordinate
  21346. * @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
  21347. * @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
  21348. * @param scene defines the hosting scene
  21349. * @param updatable defines if the mesh must be flagged as updatable
  21350. * @returns a new Mesh
  21351. */
  21352. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21353. w: number;
  21354. h: number;
  21355. }, precision: {
  21356. w: number;
  21357. h: number;
  21358. }, scene: Scene, updatable?: boolean): Mesh;
  21359. /**
  21360. * Creates a ground mesh from a height map.
  21361. * Please consider using the same method from the MeshBuilder class instead
  21362. * @see http://doc.babylonjs.com/babylon101/height_map
  21363. * @param name defines the name of the mesh to create
  21364. * @param url sets the URL of the height map image resource
  21365. * @param width set the ground width size
  21366. * @param height set the ground height size
  21367. * @param subdivisions sets the number of subdivision per side
  21368. * @param minHeight is the minimum altitude on the ground
  21369. * @param maxHeight is the maximum altitude on the ground
  21370. * @param scene defines the hosting scene
  21371. * @param updatable defines if the mesh must be flagged as updatable
  21372. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21373. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21374. * @returns a new Mesh
  21375. */
  21376. 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;
  21377. /**
  21378. * Creates a tube mesh.
  21379. * The tube is a parametric shape.
  21380. * It has no predefined shape. Its final shape will depend on the input parameters.
  21381. * Please consider using the same method from the MeshBuilder class instead
  21382. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21383. * @param name defines the name of the mesh to create
  21384. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21385. * @param radius sets the tube radius size
  21386. * @param tessellation is the number of sides on the tubular surface
  21387. * @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
  21388. * @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
  21389. * @param scene defines the hosting scene
  21390. * @param updatable defines if the mesh must be flagged as updatable
  21391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21392. * @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)
  21393. * @returns a new Mesh
  21394. */
  21395. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21396. (i: number, distance: number): number;
  21397. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21398. /**
  21399. * Creates a polyhedron mesh.
  21400. * Please consider using the same method from the MeshBuilder class instead.
  21401. * * 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
  21402. * * The parameter `size` (positive float, default 1) sets the polygon size
  21403. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21404. * * 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`
  21405. * * 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
  21406. * * 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)`)
  21407. * * 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
  21408. * * 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
  21409. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21410. * * 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
  21411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21412. * @param name defines the name of the mesh to create
  21413. * @param options defines the options used to create the mesh
  21414. * @param scene defines the hosting scene
  21415. * @returns a new Mesh
  21416. */
  21417. static CreatePolyhedron(name: string, options: {
  21418. type?: number;
  21419. size?: number;
  21420. sizeX?: number;
  21421. sizeY?: number;
  21422. sizeZ?: number;
  21423. custom?: any;
  21424. faceUV?: Vector4[];
  21425. faceColors?: Color4[];
  21426. updatable?: boolean;
  21427. sideOrientation?: number;
  21428. }, scene: Scene): Mesh;
  21429. /**
  21430. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21431. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21432. * * 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`)
  21433. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21434. * * 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
  21435. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21436. * * 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
  21437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21438. * @param name defines the name of the mesh
  21439. * @param options defines the options used to create the mesh
  21440. * @param scene defines the hosting scene
  21441. * @returns a new Mesh
  21442. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21443. */
  21444. static CreateIcoSphere(name: string, options: {
  21445. radius?: number;
  21446. flat?: boolean;
  21447. subdivisions?: number;
  21448. sideOrientation?: number;
  21449. updatable?: boolean;
  21450. }, scene: Scene): Mesh;
  21451. /**
  21452. * Creates a decal mesh.
  21453. * Please consider using the same method from the MeshBuilder class instead.
  21454. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21455. * @param name defines the name of the mesh
  21456. * @param sourceMesh defines the mesh receiving the decal
  21457. * @param position sets the position of the decal in world coordinates
  21458. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21459. * @param size sets the decal scaling
  21460. * @param angle sets the angle to rotate the decal
  21461. * @returns a new Mesh
  21462. */
  21463. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21464. /**
  21465. * Prepare internal position array for software CPU skinning
  21466. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21467. */
  21468. setPositionsForCPUSkinning(): Float32Array;
  21469. /**
  21470. * Prepare internal normal array for software CPU skinning
  21471. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21472. */
  21473. setNormalsForCPUSkinning(): Float32Array;
  21474. /**
  21475. * Updates the vertex buffer by applying transformation from the bones
  21476. * @param skeleton defines the skeleton to apply to current mesh
  21477. * @returns the current mesh
  21478. */
  21479. applySkeleton(skeleton: Skeleton): Mesh;
  21480. /**
  21481. * 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
  21482. * @param meshes defines the list of meshes to scan
  21483. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21484. */
  21485. static MinMax(meshes: AbstractMesh[]): {
  21486. min: Vector3;
  21487. max: Vector3;
  21488. };
  21489. /**
  21490. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21491. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21492. * @returns a vector3
  21493. */
  21494. static Center(meshesOrMinMaxVector: {
  21495. min: Vector3;
  21496. max: Vector3;
  21497. } | AbstractMesh[]): Vector3;
  21498. /**
  21499. * Merge the array of meshes into a single mesh for performance reasons.
  21500. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21501. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21502. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21503. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21504. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21505. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21506. * @returns a new mesh
  21507. */
  21508. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21509. /** @hidden */
  21510. addInstance(instance: InstancedMesh): void;
  21511. /** @hidden */
  21512. removeInstance(instance: InstancedMesh): void;
  21513. }
  21514. }
  21515. declare module BABYLON {
  21516. /**
  21517. * Base class for the main features of a material in Babylon.js
  21518. */
  21519. export class Material implements IAnimatable {
  21520. /**
  21521. * Returns the triangle fill mode
  21522. */
  21523. static readonly TriangleFillMode: number;
  21524. /**
  21525. * Returns the wireframe mode
  21526. */
  21527. static readonly WireFrameFillMode: number;
  21528. /**
  21529. * Returns the point fill mode
  21530. */
  21531. static readonly PointFillMode: number;
  21532. /**
  21533. * Returns the point list draw mode
  21534. */
  21535. static readonly PointListDrawMode: number;
  21536. /**
  21537. * Returns the line list draw mode
  21538. */
  21539. static readonly LineListDrawMode: number;
  21540. /**
  21541. * Returns the line loop draw mode
  21542. */
  21543. static readonly LineLoopDrawMode: number;
  21544. /**
  21545. * Returns the line strip draw mode
  21546. */
  21547. static readonly LineStripDrawMode: number;
  21548. /**
  21549. * Returns the triangle strip draw mode
  21550. */
  21551. static readonly TriangleStripDrawMode: number;
  21552. /**
  21553. * Returns the triangle fan draw mode
  21554. */
  21555. static readonly TriangleFanDrawMode: number;
  21556. /**
  21557. * Stores the clock-wise side orientation
  21558. */
  21559. static readonly ClockWiseSideOrientation: number;
  21560. /**
  21561. * Stores the counter clock-wise side orientation
  21562. */
  21563. static readonly CounterClockWiseSideOrientation: number;
  21564. /**
  21565. * The dirty texture flag value
  21566. */
  21567. static readonly TextureDirtyFlag: number;
  21568. /**
  21569. * The dirty light flag value
  21570. */
  21571. static readonly LightDirtyFlag: number;
  21572. /**
  21573. * The dirty fresnel flag value
  21574. */
  21575. static readonly FresnelDirtyFlag: number;
  21576. /**
  21577. * The dirty attribute flag value
  21578. */
  21579. static readonly AttributesDirtyFlag: number;
  21580. /**
  21581. * The dirty misc flag value
  21582. */
  21583. static readonly MiscDirtyFlag: number;
  21584. /**
  21585. * The all dirty flag value
  21586. */
  21587. static readonly AllDirtyFlag: number;
  21588. /**
  21589. * The ID of the material
  21590. */
  21591. id: string;
  21592. /**
  21593. * Gets or sets the unique id of the material
  21594. */
  21595. uniqueId: number;
  21596. /**
  21597. * The name of the material
  21598. */
  21599. name: string;
  21600. /**
  21601. * Gets or sets user defined metadata
  21602. */
  21603. metadata: any;
  21604. /**
  21605. * For internal use only. Please do not use.
  21606. */
  21607. reservedDataStore: any;
  21608. /**
  21609. * Specifies if the ready state should be checked on each call
  21610. */
  21611. checkReadyOnEveryCall: boolean;
  21612. /**
  21613. * Specifies if the ready state should be checked once
  21614. */
  21615. checkReadyOnlyOnce: boolean;
  21616. /**
  21617. * The state of the material
  21618. */
  21619. state: string;
  21620. /**
  21621. * The alpha value of the material
  21622. */
  21623. protected _alpha: number;
  21624. /**
  21625. * List of inspectable custom properties (used by the Inspector)
  21626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21627. */
  21628. inspectableCustomProperties: IInspectable[];
  21629. /**
  21630. * Sets the alpha value of the material
  21631. */
  21632. /**
  21633. * Gets the alpha value of the material
  21634. */
  21635. alpha: number;
  21636. /**
  21637. * Specifies if back face culling is enabled
  21638. */
  21639. protected _backFaceCulling: boolean;
  21640. /**
  21641. * Sets the back-face culling state
  21642. */
  21643. /**
  21644. * Gets the back-face culling state
  21645. */
  21646. backFaceCulling: boolean;
  21647. /**
  21648. * Stores the value for side orientation
  21649. */
  21650. sideOrientation: number;
  21651. /**
  21652. * Callback triggered when the material is compiled
  21653. */
  21654. onCompiled: Nullable<(effect: Effect) => void>;
  21655. /**
  21656. * Callback triggered when an error occurs
  21657. */
  21658. onError: Nullable<(effect: Effect, errors: string) => void>;
  21659. /**
  21660. * Callback triggered to get the render target textures
  21661. */
  21662. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21663. /**
  21664. * Gets a boolean indicating that current material needs to register RTT
  21665. */
  21666. readonly hasRenderTargetTextures: boolean;
  21667. /**
  21668. * Specifies if the material should be serialized
  21669. */
  21670. doNotSerialize: boolean;
  21671. /**
  21672. * @hidden
  21673. */ private _storeEffectOnSubMeshes: boolean;
  21674. /**
  21675. * Stores the animations for the material
  21676. */
  21677. animations: Nullable<Array<Animation>>;
  21678. /**
  21679. * An event triggered when the material is disposed
  21680. */
  21681. onDisposeObservable: Observable<Material>;
  21682. /**
  21683. * An observer which watches for dispose events
  21684. */
  21685. private _onDisposeObserver;
  21686. private _onUnBindObservable;
  21687. /**
  21688. * Called during a dispose event
  21689. */
  21690. onDispose: () => void;
  21691. private _onBindObservable;
  21692. /**
  21693. * An event triggered when the material is bound
  21694. */
  21695. readonly onBindObservable: Observable<AbstractMesh>;
  21696. /**
  21697. * An observer which watches for bind events
  21698. */
  21699. private _onBindObserver;
  21700. /**
  21701. * Called during a bind event
  21702. */
  21703. onBind: (Mesh: AbstractMesh) => void;
  21704. /**
  21705. * An event triggered when the material is unbound
  21706. */
  21707. readonly onUnBindObservable: Observable<Material>;
  21708. /**
  21709. * Stores the value of the alpha mode
  21710. */
  21711. private _alphaMode;
  21712. /**
  21713. * Sets the value of the alpha mode.
  21714. *
  21715. * | Value | Type | Description |
  21716. * | --- | --- | --- |
  21717. * | 0 | ALPHA_DISABLE | |
  21718. * | 1 | ALPHA_ADD | |
  21719. * | 2 | ALPHA_COMBINE | |
  21720. * | 3 | ALPHA_SUBTRACT | |
  21721. * | 4 | ALPHA_MULTIPLY | |
  21722. * | 5 | ALPHA_MAXIMIZED | |
  21723. * | 6 | ALPHA_ONEONE | |
  21724. * | 7 | ALPHA_PREMULTIPLIED | |
  21725. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21726. * | 9 | ALPHA_INTERPOLATE | |
  21727. * | 10 | ALPHA_SCREENMODE | |
  21728. *
  21729. */
  21730. /**
  21731. * Gets the value of the alpha mode
  21732. */
  21733. alphaMode: number;
  21734. /**
  21735. * Stores the state of the need depth pre-pass value
  21736. */
  21737. private _needDepthPrePass;
  21738. /**
  21739. * Sets the need depth pre-pass value
  21740. */
  21741. /**
  21742. * Gets the depth pre-pass value
  21743. */
  21744. needDepthPrePass: boolean;
  21745. /**
  21746. * Specifies if depth writing should be disabled
  21747. */
  21748. disableDepthWrite: boolean;
  21749. /**
  21750. * Specifies if depth writing should be forced
  21751. */
  21752. forceDepthWrite: boolean;
  21753. /**
  21754. * Specifies if there should be a separate pass for culling
  21755. */
  21756. separateCullingPass: boolean;
  21757. /**
  21758. * Stores the state specifing if fog should be enabled
  21759. */
  21760. private _fogEnabled;
  21761. /**
  21762. * Sets the state for enabling fog
  21763. */
  21764. /**
  21765. * Gets the value of the fog enabled state
  21766. */
  21767. fogEnabled: boolean;
  21768. /**
  21769. * Stores the size of points
  21770. */
  21771. pointSize: number;
  21772. /**
  21773. * Stores the z offset value
  21774. */
  21775. zOffset: number;
  21776. /**
  21777. * Gets a value specifying if wireframe mode is enabled
  21778. */
  21779. /**
  21780. * Sets the state of wireframe mode
  21781. */
  21782. wireframe: boolean;
  21783. /**
  21784. * Gets the value specifying if point clouds are enabled
  21785. */
  21786. /**
  21787. * Sets the state of point cloud mode
  21788. */
  21789. pointsCloud: boolean;
  21790. /**
  21791. * Gets the material fill mode
  21792. */
  21793. /**
  21794. * Sets the material fill mode
  21795. */
  21796. fillMode: number;
  21797. /**
  21798. * @hidden
  21799. * Stores the effects for the material
  21800. */ private _effect: Nullable<Effect>;
  21801. /**
  21802. * @hidden
  21803. * Specifies if the material was previously ready
  21804. */ private _wasPreviouslyReady: boolean;
  21805. /**
  21806. * Specifies if uniform buffers should be used
  21807. */
  21808. private _useUBO;
  21809. /**
  21810. * Stores a reference to the scene
  21811. */
  21812. private _scene;
  21813. /**
  21814. * Stores the fill mode state
  21815. */
  21816. private _fillMode;
  21817. /**
  21818. * Specifies if the depth write state should be cached
  21819. */
  21820. private _cachedDepthWriteState;
  21821. /**
  21822. * Stores the uniform buffer
  21823. */
  21824. protected _uniformBuffer: UniformBuffer;
  21825. /** @hidden */ private _indexInSceneMaterialArray: number;
  21826. /** @hidden */
  21827. meshMap: Nullable<{
  21828. [id: string]: AbstractMesh | undefined;
  21829. }>;
  21830. /**
  21831. * Creates a material instance
  21832. * @param name defines the name of the material
  21833. * @param scene defines the scene to reference
  21834. * @param doNotAdd specifies if the material should be added to the scene
  21835. */
  21836. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21837. /**
  21838. * Returns a string representation of the current material
  21839. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21840. * @returns a string with material information
  21841. */
  21842. toString(fullDetails?: boolean): string;
  21843. /**
  21844. * Gets the class name of the material
  21845. * @returns a string with the class name of the material
  21846. */
  21847. getClassName(): string;
  21848. /**
  21849. * Specifies if updates for the material been locked
  21850. */
  21851. readonly isFrozen: boolean;
  21852. /**
  21853. * Locks updates for the material
  21854. */
  21855. freeze(): void;
  21856. /**
  21857. * Unlocks updates for the material
  21858. */
  21859. unfreeze(): void;
  21860. /**
  21861. * Specifies if the material is ready to be used
  21862. * @param mesh defines the mesh to check
  21863. * @param useInstances specifies if instances should be used
  21864. * @returns a boolean indicating if the material is ready to be used
  21865. */
  21866. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21867. /**
  21868. * Specifies that the submesh is ready to be used
  21869. * @param mesh defines the mesh to check
  21870. * @param subMesh defines which submesh to check
  21871. * @param useInstances specifies that instances should be used
  21872. * @returns a boolean indicating that the submesh is ready or not
  21873. */
  21874. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21875. /**
  21876. * Returns the material effect
  21877. * @returns the effect associated with the material
  21878. */
  21879. getEffect(): Nullable<Effect>;
  21880. /**
  21881. * Returns the current scene
  21882. * @returns a Scene
  21883. */
  21884. getScene(): Scene;
  21885. /**
  21886. * Specifies if the material will require alpha blending
  21887. * @returns a boolean specifying if alpha blending is needed
  21888. */
  21889. needAlphaBlending(): boolean;
  21890. /**
  21891. * Specifies if the mesh will require alpha blending
  21892. * @param mesh defines the mesh to check
  21893. * @returns a boolean specifying if alpha blending is needed for the mesh
  21894. */
  21895. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21896. /**
  21897. * Specifies if this material should be rendered in alpha test mode
  21898. * @returns a boolean specifying if an alpha test is needed.
  21899. */
  21900. needAlphaTesting(): boolean;
  21901. /**
  21902. * Gets the texture used for the alpha test
  21903. * @returns the texture to use for alpha testing
  21904. */
  21905. getAlphaTestTexture(): Nullable<BaseTexture>;
  21906. /**
  21907. * Marks the material to indicate that it needs to be re-calculated
  21908. */
  21909. markDirty(): void;
  21910. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21911. /**
  21912. * Binds the material to the mesh
  21913. * @param world defines the world transformation matrix
  21914. * @param mesh defines the mesh to bind the material to
  21915. */
  21916. bind(world: Matrix, mesh?: Mesh): void;
  21917. /**
  21918. * Binds the submesh to the material
  21919. * @param world defines the world transformation matrix
  21920. * @param mesh defines the mesh containing the submesh
  21921. * @param subMesh defines the submesh to bind the material to
  21922. */
  21923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21924. /**
  21925. * Binds the world matrix to the material
  21926. * @param world defines the world transformation matrix
  21927. */
  21928. bindOnlyWorldMatrix(world: Matrix): void;
  21929. /**
  21930. * Binds the scene's uniform buffer to the effect.
  21931. * @param effect defines the effect to bind to the scene uniform buffer
  21932. * @param sceneUbo defines the uniform buffer storing scene data
  21933. */
  21934. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21935. /**
  21936. * Binds the view matrix to the effect
  21937. * @param effect defines the effect to bind the view matrix to
  21938. */
  21939. bindView(effect: Effect): void;
  21940. /**
  21941. * Binds the view projection matrix to the effect
  21942. * @param effect defines the effect to bind the view projection matrix to
  21943. */
  21944. bindViewProjection(effect: Effect): void;
  21945. /**
  21946. * Specifies if material alpha testing should be turned on for the mesh
  21947. * @param mesh defines the mesh to check
  21948. */
  21949. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21950. /**
  21951. * Processes to execute after binding the material to a mesh
  21952. * @param mesh defines the rendered mesh
  21953. */
  21954. protected _afterBind(mesh?: Mesh): void;
  21955. /**
  21956. * Unbinds the material from the mesh
  21957. */
  21958. unbind(): void;
  21959. /**
  21960. * Gets the active textures from the material
  21961. * @returns an array of textures
  21962. */
  21963. getActiveTextures(): BaseTexture[];
  21964. /**
  21965. * Specifies if the material uses a texture
  21966. * @param texture defines the texture to check against the material
  21967. * @returns a boolean specifying if the material uses the texture
  21968. */
  21969. hasTexture(texture: BaseTexture): boolean;
  21970. /**
  21971. * Makes a duplicate of the material, and gives it a new name
  21972. * @param name defines the new name for the duplicated material
  21973. * @returns the cloned material
  21974. */
  21975. clone(name: string): Nullable<Material>;
  21976. /**
  21977. * Gets the meshes bound to the material
  21978. * @returns an array of meshes bound to the material
  21979. */
  21980. getBindedMeshes(): AbstractMesh[];
  21981. /**
  21982. * Force shader compilation
  21983. * @param mesh defines the mesh associated with this material
  21984. * @param onCompiled defines a function to execute once the material is compiled
  21985. * @param options defines the options to configure the compilation
  21986. */
  21987. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21988. clipPlane: boolean;
  21989. }>): void;
  21990. /**
  21991. * Force shader compilation
  21992. * @param mesh defines the mesh that will use this material
  21993. * @param options defines additional options for compiling the shaders
  21994. * @returns a promise that resolves when the compilation completes
  21995. */
  21996. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21997. clipPlane: boolean;
  21998. }>): Promise<void>;
  21999. private static readonly _AllDirtyCallBack;
  22000. private static readonly _ImageProcessingDirtyCallBack;
  22001. private static readonly _TextureDirtyCallBack;
  22002. private static readonly _FresnelDirtyCallBack;
  22003. private static readonly _MiscDirtyCallBack;
  22004. private static readonly _LightsDirtyCallBack;
  22005. private static readonly _AttributeDirtyCallBack;
  22006. private static _FresnelAndMiscDirtyCallBack;
  22007. private static _TextureAndMiscDirtyCallBack;
  22008. private static readonly _DirtyCallbackArray;
  22009. private static readonly _RunDirtyCallBacks;
  22010. /**
  22011. * Marks a define in the material to indicate that it needs to be re-computed
  22012. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22013. */
  22014. markAsDirty(flag: number): void;
  22015. /**
  22016. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22017. * @param func defines a function which checks material defines against the submeshes
  22018. */
  22019. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22020. /**
  22021. * Indicates that we need to re-calculated for all submeshes
  22022. */
  22023. protected _markAllSubMeshesAsAllDirty(): void;
  22024. /**
  22025. * Indicates that image processing needs to be re-calculated for all submeshes
  22026. */
  22027. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22028. /**
  22029. * Indicates that textures need to be re-calculated for all submeshes
  22030. */
  22031. protected _markAllSubMeshesAsTexturesDirty(): void;
  22032. /**
  22033. * Indicates that fresnel needs to be re-calculated for all submeshes
  22034. */
  22035. protected _markAllSubMeshesAsFresnelDirty(): void;
  22036. /**
  22037. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22038. */
  22039. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22040. /**
  22041. * Indicates that lights need to be re-calculated for all submeshes
  22042. */
  22043. protected _markAllSubMeshesAsLightsDirty(): void;
  22044. /**
  22045. * Indicates that attributes need to be re-calculated for all submeshes
  22046. */
  22047. protected _markAllSubMeshesAsAttributesDirty(): void;
  22048. /**
  22049. * Indicates that misc needs to be re-calculated for all submeshes
  22050. */
  22051. protected _markAllSubMeshesAsMiscDirty(): void;
  22052. /**
  22053. * Indicates that textures and misc need to be re-calculated for all submeshes
  22054. */
  22055. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22056. /**
  22057. * Disposes the material
  22058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22061. */
  22062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22063. /** @hidden */
  22064. private releaseVertexArrayObject;
  22065. /**
  22066. * Serializes this material
  22067. * @returns the serialized material object
  22068. */
  22069. serialize(): any;
  22070. /**
  22071. * Creates a material from parsed material data
  22072. * @param parsedMaterial defines parsed material data
  22073. * @param scene defines the hosting scene
  22074. * @param rootUrl defines the root URL to use to load textures
  22075. * @returns a new material
  22076. */
  22077. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22078. }
  22079. }
  22080. declare module BABYLON {
  22081. /**
  22082. * Base class for submeshes
  22083. */
  22084. export class BaseSubMesh {
  22085. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  22086. /** @hidden */ private _materialEffect: Nullable<Effect>;
  22087. /**
  22088. * Gets associated effect
  22089. */
  22090. readonly effect: Nullable<Effect>;
  22091. /**
  22092. * Sets associated effect (effect used to render this submesh)
  22093. * @param effect defines the effect to associate with
  22094. * @param defines defines the set of defines used to compile this effect
  22095. */
  22096. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22097. }
  22098. /**
  22099. * Defines a subdivision inside a mesh
  22100. */
  22101. export class SubMesh extends BaseSubMesh implements ICullable {
  22102. /** the material index to use */
  22103. materialIndex: number;
  22104. /** vertex index start */
  22105. verticesStart: number;
  22106. /** vertices count */
  22107. verticesCount: number;
  22108. /** index start */
  22109. indexStart: number;
  22110. /** indices count */
  22111. indexCount: number;
  22112. /** @hidden */ private _linesIndexCount: number;
  22113. private _mesh;
  22114. private _renderingMesh;
  22115. private _boundingInfo;
  22116. private _linesIndexBuffer;
  22117. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  22118. /** @hidden */ private _trianglePlanes: Plane[];
  22119. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  22120. /** @hidden */ private _renderId: number;
  22121. /** @hidden */ private _alphaIndex: number;
  22122. /** @hidden */ private _distanceToCamera: number;
  22123. /** @hidden */ private _id: number;
  22124. private _currentMaterial;
  22125. /**
  22126. * Add a new submesh to a mesh
  22127. * @param materialIndex defines the material index to use
  22128. * @param verticesStart defines vertex index start
  22129. * @param verticesCount defines vertices count
  22130. * @param indexStart defines index start
  22131. * @param indexCount defines indices count
  22132. * @param mesh defines the parent mesh
  22133. * @param renderingMesh defines an optional rendering mesh
  22134. * @param createBoundingBox defines if bounding box should be created for this submesh
  22135. * @returns the new submesh
  22136. */
  22137. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22138. /**
  22139. * Creates a new submesh
  22140. * @param materialIndex defines the material index to use
  22141. * @param verticesStart defines vertex index start
  22142. * @param verticesCount defines vertices count
  22143. * @param indexStart defines index start
  22144. * @param indexCount defines indices count
  22145. * @param mesh defines the parent mesh
  22146. * @param renderingMesh defines an optional rendering mesh
  22147. * @param createBoundingBox defines if bounding box should be created for this submesh
  22148. */
  22149. constructor(
  22150. /** the material index to use */
  22151. materialIndex: number,
  22152. /** vertex index start */
  22153. verticesStart: number,
  22154. /** vertices count */
  22155. verticesCount: number,
  22156. /** index start */
  22157. indexStart: number,
  22158. /** indices count */
  22159. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22160. /**
  22161. * Returns true if this submesh covers the entire parent mesh
  22162. * @ignorenaming
  22163. */
  22164. readonly IsGlobal: boolean;
  22165. /**
  22166. * Returns the submesh BoudingInfo object
  22167. * @returns current bounding info (or mesh's one if the submesh is global)
  22168. */
  22169. getBoundingInfo(): BoundingInfo;
  22170. /**
  22171. * Sets the submesh BoundingInfo
  22172. * @param boundingInfo defines the new bounding info to use
  22173. * @returns the SubMesh
  22174. */
  22175. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22176. /**
  22177. * Returns the mesh of the current submesh
  22178. * @return the parent mesh
  22179. */
  22180. getMesh(): AbstractMesh;
  22181. /**
  22182. * Returns the rendering mesh of the submesh
  22183. * @returns the rendering mesh (could be different from parent mesh)
  22184. */
  22185. getRenderingMesh(): Mesh;
  22186. /**
  22187. * Returns the submesh material
  22188. * @returns null or the current material
  22189. */
  22190. getMaterial(): Nullable<Material>;
  22191. /**
  22192. * Sets a new updated BoundingInfo object to the submesh
  22193. * @param data defines an optional position array to use to determine the bounding info
  22194. * @returns the SubMesh
  22195. */
  22196. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22197. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  22198. /**
  22199. * Updates the submesh BoundingInfo
  22200. * @param world defines the world matrix to use to update the bounding info
  22201. * @returns the submesh
  22202. */
  22203. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22204. /**
  22205. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22206. * @param frustumPlanes defines the frustum planes
  22207. * @returns true if the submesh is intersecting with the frustum
  22208. */
  22209. isInFrustum(frustumPlanes: Plane[]): boolean;
  22210. /**
  22211. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22212. * @param frustumPlanes defines the frustum planes
  22213. * @returns true if the submesh is inside the frustum
  22214. */
  22215. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22216. /**
  22217. * Renders the submesh
  22218. * @param enableAlphaMode defines if alpha needs to be used
  22219. * @returns the submesh
  22220. */
  22221. render(enableAlphaMode: boolean): SubMesh;
  22222. /**
  22223. * @hidden
  22224. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22225. /**
  22226. * Checks if the submesh intersects with a ray
  22227. * @param ray defines the ray to test
  22228. * @returns true is the passed ray intersects the submesh bounding box
  22229. */
  22230. canIntersects(ray: Ray): boolean;
  22231. /**
  22232. * Intersects current submesh with a ray
  22233. * @param ray defines the ray to test
  22234. * @param positions defines mesh's positions array
  22235. * @param indices defines mesh's indices array
  22236. * @param fastCheck defines if only bounding info should be used
  22237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22238. * @returns intersection info or null if no intersection
  22239. */
  22240. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22241. /** @hidden */
  22242. private _intersectLines;
  22243. /** @hidden */
  22244. private _intersectUnIndexedLines;
  22245. /** @hidden */
  22246. private _intersectTriangles;
  22247. /** @hidden */
  22248. private _intersectUnIndexedTriangles;
  22249. /** @hidden */ private _rebuild(): void;
  22250. /**
  22251. * Creates a new submesh from the passed mesh
  22252. * @param newMesh defines the new hosting mesh
  22253. * @param newRenderingMesh defines an optional rendering mesh
  22254. * @returns the new submesh
  22255. */
  22256. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22257. /**
  22258. * Release associated resources
  22259. */
  22260. dispose(): void;
  22261. /**
  22262. * Gets the class name
  22263. * @returns the string "SubMesh".
  22264. */
  22265. getClassName(): string;
  22266. /**
  22267. * Creates a new submesh from indices data
  22268. * @param materialIndex the index of the main mesh material
  22269. * @param startIndex the index where to start the copy in the mesh indices array
  22270. * @param indexCount the number of indices to copy then from the startIndex
  22271. * @param mesh the main mesh to create the submesh from
  22272. * @param renderingMesh the optional rendering mesh
  22273. * @returns a new submesh
  22274. */
  22275. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22276. }
  22277. }
  22278. declare module BABYLON {
  22279. /**
  22280. * Class used to store geometry data (vertex buffers + index buffer)
  22281. */
  22282. export class Geometry implements IGetSetVerticesData {
  22283. /**
  22284. * Gets or sets the ID of the geometry
  22285. */
  22286. id: string;
  22287. /**
  22288. * Gets or sets the unique ID of the geometry
  22289. */
  22290. uniqueId: number;
  22291. /**
  22292. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22293. */
  22294. delayLoadState: number;
  22295. /**
  22296. * Gets the file containing the data to load when running in delay load state
  22297. */
  22298. delayLoadingFile: Nullable<string>;
  22299. /**
  22300. * Callback called when the geometry is updated
  22301. */
  22302. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22303. private _scene;
  22304. private _engine;
  22305. private _meshes;
  22306. private _totalVertices;
  22307. /** @hidden */ private _indices: IndicesArray;
  22308. /** @hidden */ private _vertexBuffers: {
  22309. [key: string]: VertexBuffer;
  22310. };
  22311. private _isDisposed;
  22312. private _extend;
  22313. private _boundingBias;
  22314. /** @hidden */ private _delayInfo: Array<string>;
  22315. private _indexBuffer;
  22316. private _indexBufferIsUpdatable;
  22317. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  22318. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22319. /** @hidden */ private _softwareSkinningFrameId: number;
  22320. private _vertexArrayObjects;
  22321. private _updatable;
  22322. /** @hidden */ private _positions: Nullable<Vector3[]>;
  22323. /**
  22324. * 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
  22325. */
  22326. /**
  22327. * 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
  22328. */
  22329. boundingBias: Vector2;
  22330. /**
  22331. * Static function used to attach a new empty geometry to a mesh
  22332. * @param mesh defines the mesh to attach the geometry to
  22333. * @returns the new Geometry
  22334. */
  22335. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22336. /**
  22337. * Creates a new geometry
  22338. * @param id defines the unique ID
  22339. * @param scene defines the hosting scene
  22340. * @param vertexData defines the VertexData used to get geometry data
  22341. * @param updatable defines if geometry must be updatable (false by default)
  22342. * @param mesh defines the mesh that will be associated with the geometry
  22343. */
  22344. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22345. /**
  22346. * Gets the current extend of the geometry
  22347. */
  22348. readonly extend: {
  22349. minimum: Vector3;
  22350. maximum: Vector3;
  22351. };
  22352. /**
  22353. * Gets the hosting scene
  22354. * @returns the hosting Scene
  22355. */
  22356. getScene(): Scene;
  22357. /**
  22358. * Gets the hosting engine
  22359. * @returns the hosting Engine
  22360. */
  22361. getEngine(): Engine;
  22362. /**
  22363. * Defines if the geometry is ready to use
  22364. * @returns true if the geometry is ready to be used
  22365. */
  22366. isReady(): boolean;
  22367. /**
  22368. * Gets a value indicating that the geometry should not be serialized
  22369. */
  22370. readonly doNotSerialize: boolean;
  22371. /** @hidden */ private _rebuild(): void;
  22372. /**
  22373. * Affects all geometry data in one call
  22374. * @param vertexData defines the geometry data
  22375. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22376. */
  22377. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22378. /**
  22379. * Set specific vertex data
  22380. * @param kind defines the data kind (Position, normal, etc...)
  22381. * @param data defines the vertex data to use
  22382. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22383. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22384. */
  22385. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22386. /**
  22387. * Removes a specific vertex data
  22388. * @param kind defines the data kind (Position, normal, etc...)
  22389. */
  22390. removeVerticesData(kind: string): void;
  22391. /**
  22392. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22393. * @param buffer defines the vertex buffer to use
  22394. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22395. */
  22396. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22397. /**
  22398. * Update a specific vertex buffer
  22399. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22400. * It will do nothing if the buffer is not updatable
  22401. * @param kind defines the data kind (Position, normal, etc...)
  22402. * @param data defines the data to use
  22403. * @param offset defines the offset in the target buffer where to store the data
  22404. * @param useBytes set to true if the offset is in bytes
  22405. */
  22406. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22407. /**
  22408. * Update a specific vertex buffer
  22409. * This function will create a new buffer if the current one is not updatable
  22410. * @param kind defines the data kind (Position, normal, etc...)
  22411. * @param data defines the data to use
  22412. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22413. */
  22414. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22415. private _updateBoundingInfo;
  22416. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22417. /**
  22418. * Gets total number of vertices
  22419. * @returns the total number of vertices
  22420. */
  22421. getTotalVertices(): number;
  22422. /**
  22423. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22424. * @param kind defines the data kind (Position, normal, etc...)
  22425. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22426. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22427. * @returns a float array containing vertex data
  22428. */
  22429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22430. /**
  22431. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22432. * @param kind defines the data kind (Position, normal, etc...)
  22433. * @returns true if the vertex buffer with the specified kind is updatable
  22434. */
  22435. isVertexBufferUpdatable(kind: string): boolean;
  22436. /**
  22437. * Gets a specific vertex buffer
  22438. * @param kind defines the data kind (Position, normal, etc...)
  22439. * @returns a VertexBuffer
  22440. */
  22441. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22442. /**
  22443. * Returns all vertex buffers
  22444. * @return an object holding all vertex buffers indexed by kind
  22445. */
  22446. getVertexBuffers(): Nullable<{
  22447. [key: string]: VertexBuffer;
  22448. }>;
  22449. /**
  22450. * Gets a boolean indicating if specific vertex buffer is present
  22451. * @param kind defines the data kind (Position, normal, etc...)
  22452. * @returns true if data is present
  22453. */
  22454. isVerticesDataPresent(kind: string): boolean;
  22455. /**
  22456. * Gets a list of all attached data kinds (Position, normal, etc...)
  22457. * @returns a list of string containing all kinds
  22458. */
  22459. getVerticesDataKinds(): string[];
  22460. /**
  22461. * Update index buffer
  22462. * @param indices defines the indices to store in the index buffer
  22463. * @param offset defines the offset in the target buffer where to store the data
  22464. * @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)
  22465. */
  22466. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22467. /**
  22468. * Creates a new index buffer
  22469. * @param indices defines the indices to store in the index buffer
  22470. * @param totalVertices defines the total number of vertices (could be null)
  22471. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22472. */
  22473. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22474. /**
  22475. * Return the total number of indices
  22476. * @returns the total number of indices
  22477. */
  22478. getTotalIndices(): number;
  22479. /**
  22480. * Gets the index buffer array
  22481. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22482. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22483. * @returns the index buffer array
  22484. */
  22485. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22486. /**
  22487. * Gets the index buffer
  22488. * @return the index buffer
  22489. */
  22490. getIndexBuffer(): Nullable<DataBuffer>;
  22491. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22492. /**
  22493. * Release the associated resources for a specific mesh
  22494. * @param mesh defines the source mesh
  22495. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22496. */
  22497. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22498. /**
  22499. * Apply current geometry to a given mesh
  22500. * @param mesh defines the mesh to apply geometry to
  22501. */
  22502. applyToMesh(mesh: Mesh): void;
  22503. private _updateExtend;
  22504. private _applyToMesh;
  22505. private notifyUpdate;
  22506. /**
  22507. * Load the geometry if it was flagged as delay loaded
  22508. * @param scene defines the hosting scene
  22509. * @param onLoaded defines a callback called when the geometry is loaded
  22510. */
  22511. load(scene: Scene, onLoaded?: () => void): void;
  22512. private _queueLoad;
  22513. /**
  22514. * Invert the geometry to move from a right handed system to a left handed one.
  22515. */
  22516. toLeftHanded(): void;
  22517. /** @hidden */ private _resetPointsArrayCache(): void;
  22518. /** @hidden */ private _generatePointsArray(): boolean;
  22519. /**
  22520. * Gets a value indicating if the geometry is disposed
  22521. * @returns true if the geometry was disposed
  22522. */
  22523. isDisposed(): boolean;
  22524. private _disposeVertexArrayObjects;
  22525. /**
  22526. * Free all associated resources
  22527. */
  22528. dispose(): void;
  22529. /**
  22530. * Clone the current geometry into a new geometry
  22531. * @param id defines the unique ID of the new geometry
  22532. * @returns a new geometry object
  22533. */
  22534. copy(id: string): Geometry;
  22535. /**
  22536. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22537. * @return a JSON representation of the current geometry data (without the vertices data)
  22538. */
  22539. serialize(): any;
  22540. private toNumberArray;
  22541. /**
  22542. * Serialize all vertices data into a JSON oject
  22543. * @returns a JSON representation of the current geometry data
  22544. */
  22545. serializeVerticeData(): any;
  22546. /**
  22547. * Extracts a clone of a mesh geometry
  22548. * @param mesh defines the source mesh
  22549. * @param id defines the unique ID of the new geometry object
  22550. * @returns the new geometry object
  22551. */
  22552. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22553. /**
  22554. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22555. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22556. * Be aware Math.random() could cause collisions, but:
  22557. * "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"
  22558. * @returns a string containing a new GUID
  22559. */
  22560. static RandomId(): string;
  22561. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22562. private static _CleanMatricesWeights;
  22563. /**
  22564. * Create a new geometry from persisted data (Using .babylon file format)
  22565. * @param parsedVertexData defines the persisted data
  22566. * @param scene defines the hosting scene
  22567. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22568. * @returns the new geometry object
  22569. */
  22570. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22571. }
  22572. }
  22573. declare module BABYLON {
  22574. /**
  22575. * Define an interface for all classes that will get and set the data on vertices
  22576. */
  22577. export interface IGetSetVerticesData {
  22578. /**
  22579. * Gets a boolean indicating if specific vertex data is present
  22580. * @param kind defines the vertex data kind to use
  22581. * @returns true is data kind is present
  22582. */
  22583. isVerticesDataPresent(kind: string): boolean;
  22584. /**
  22585. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22586. * @param kind defines the data kind (Position, normal, etc...)
  22587. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22588. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22589. * @returns a float array containing vertex data
  22590. */
  22591. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22592. /**
  22593. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22594. * @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.
  22595. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22596. * @returns the indices array or an empty array if the mesh has no geometry
  22597. */
  22598. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22599. /**
  22600. * Set specific vertex data
  22601. * @param kind defines the data kind (Position, normal, etc...)
  22602. * @param data defines the vertex data to use
  22603. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22604. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22605. */
  22606. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22607. /**
  22608. * Update a specific associated vertex buffer
  22609. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22610. * - VertexBuffer.PositionKind
  22611. * - VertexBuffer.UVKind
  22612. * - VertexBuffer.UV2Kind
  22613. * - VertexBuffer.UV3Kind
  22614. * - VertexBuffer.UV4Kind
  22615. * - VertexBuffer.UV5Kind
  22616. * - VertexBuffer.UV6Kind
  22617. * - VertexBuffer.ColorKind
  22618. * - VertexBuffer.MatricesIndicesKind
  22619. * - VertexBuffer.MatricesIndicesExtraKind
  22620. * - VertexBuffer.MatricesWeightsKind
  22621. * - VertexBuffer.MatricesWeightsExtraKind
  22622. * @param data defines the data source
  22623. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22624. * @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)
  22625. */
  22626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22627. /**
  22628. * Creates a new index buffer
  22629. * @param indices defines the indices to store in the index buffer
  22630. * @param totalVertices defines the total number of vertices (could be null)
  22631. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22632. */
  22633. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22634. }
  22635. /**
  22636. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22637. */
  22638. export class VertexData {
  22639. /**
  22640. * Mesh side orientation : usually the external or front surface
  22641. */
  22642. static readonly FRONTSIDE: number;
  22643. /**
  22644. * Mesh side orientation : usually the internal or back surface
  22645. */
  22646. static readonly BACKSIDE: number;
  22647. /**
  22648. * Mesh side orientation : both internal and external or front and back surfaces
  22649. */
  22650. static readonly DOUBLESIDE: number;
  22651. /**
  22652. * Mesh side orientation : by default, `FRONTSIDE`
  22653. */
  22654. static readonly DEFAULTSIDE: number;
  22655. /**
  22656. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22657. */
  22658. positions: Nullable<FloatArray>;
  22659. /**
  22660. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22661. */
  22662. normals: Nullable<FloatArray>;
  22663. /**
  22664. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22665. */
  22666. tangents: Nullable<FloatArray>;
  22667. /**
  22668. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22669. */
  22670. uvs: Nullable<FloatArray>;
  22671. /**
  22672. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22673. */
  22674. uvs2: Nullable<FloatArray>;
  22675. /**
  22676. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22677. */
  22678. uvs3: Nullable<FloatArray>;
  22679. /**
  22680. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22681. */
  22682. uvs4: Nullable<FloatArray>;
  22683. /**
  22684. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22685. */
  22686. uvs5: Nullable<FloatArray>;
  22687. /**
  22688. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22689. */
  22690. uvs6: Nullable<FloatArray>;
  22691. /**
  22692. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22693. */
  22694. colors: Nullable<FloatArray>;
  22695. /**
  22696. * 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).
  22697. */
  22698. matricesIndices: Nullable<FloatArray>;
  22699. /**
  22700. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22701. */
  22702. matricesWeights: Nullable<FloatArray>;
  22703. /**
  22704. * An array extending the number of possible indices
  22705. */
  22706. matricesIndicesExtra: Nullable<FloatArray>;
  22707. /**
  22708. * An array extending the number of possible weights when the number of indices is extended
  22709. */
  22710. matricesWeightsExtra: Nullable<FloatArray>;
  22711. /**
  22712. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22713. */
  22714. indices: Nullable<IndicesArray>;
  22715. /**
  22716. * Uses the passed data array to set the set the values for the specified kind of data
  22717. * @param data a linear array of floating numbers
  22718. * @param kind the type of data that is being set, eg positions, colors etc
  22719. */
  22720. set(data: FloatArray, kind: string): void;
  22721. /**
  22722. * Associates the vertexData to the passed Mesh.
  22723. * Sets it as updatable or not (default `false`)
  22724. * @param mesh the mesh the vertexData is applied to
  22725. * @param updatable when used and having the value true allows new data to update the vertexData
  22726. * @returns the VertexData
  22727. */
  22728. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22729. /**
  22730. * Associates the vertexData to the passed Geometry.
  22731. * Sets it as updatable or not (default `false`)
  22732. * @param geometry the geometry the vertexData is applied to
  22733. * @param updatable when used and having the value true allows new data to update the vertexData
  22734. * @returns VertexData
  22735. */
  22736. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22737. /**
  22738. * Updates the associated mesh
  22739. * @param mesh the mesh to be updated
  22740. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22741. * @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
  22742. * @returns VertexData
  22743. */
  22744. updateMesh(mesh: Mesh): VertexData;
  22745. /**
  22746. * Updates the associated geometry
  22747. * @param geometry the geometry to be updated
  22748. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22749. * @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
  22750. * @returns VertexData.
  22751. */
  22752. updateGeometry(geometry: Geometry): VertexData;
  22753. private _applyTo;
  22754. private _update;
  22755. /**
  22756. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22757. * @param matrix the transforming matrix
  22758. * @returns the VertexData
  22759. */
  22760. transform(matrix: Matrix): VertexData;
  22761. /**
  22762. * Merges the passed VertexData into the current one
  22763. * @param other the VertexData to be merged into the current one
  22764. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22765. * @returns the modified VertexData
  22766. */
  22767. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22768. private _mergeElement;
  22769. private _validate;
  22770. /**
  22771. * Serializes the VertexData
  22772. * @returns a serialized object
  22773. */
  22774. serialize(): any;
  22775. /**
  22776. * Extracts the vertexData from a mesh
  22777. * @param mesh the mesh from which to extract the VertexData
  22778. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22779. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22780. * @returns the object VertexData associated to the passed mesh
  22781. */
  22782. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22783. /**
  22784. * Extracts the vertexData from the geometry
  22785. * @param geometry the geometry from which to extract the VertexData
  22786. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22787. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22788. * @returns the object VertexData associated to the passed mesh
  22789. */
  22790. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22791. private static _ExtractFrom;
  22792. /**
  22793. * Creates the VertexData for a Ribbon
  22794. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22795. * * pathArray array of paths, each of which an array of successive Vector3
  22796. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22797. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22798. * * 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
  22799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22800. * * 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)
  22801. * * 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)
  22802. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22803. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22804. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22805. * @returns the VertexData of the ribbon
  22806. */
  22807. static CreateRibbon(options: {
  22808. pathArray: Vector3[][];
  22809. closeArray?: boolean;
  22810. closePath?: boolean;
  22811. offset?: number;
  22812. sideOrientation?: number;
  22813. frontUVs?: Vector4;
  22814. backUVs?: Vector4;
  22815. invertUV?: boolean;
  22816. uvs?: Vector2[];
  22817. colors?: Color4[];
  22818. }): VertexData;
  22819. /**
  22820. * Creates the VertexData for a box
  22821. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22822. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22823. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22824. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22825. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22826. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22827. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22829. * * 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)
  22830. * * 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)
  22831. * @returns the VertexData of the box
  22832. */
  22833. static CreateBox(options: {
  22834. size?: number;
  22835. width?: number;
  22836. height?: number;
  22837. depth?: number;
  22838. faceUV?: Vector4[];
  22839. faceColors?: Color4[];
  22840. sideOrientation?: number;
  22841. frontUVs?: Vector4;
  22842. backUVs?: Vector4;
  22843. }): VertexData;
  22844. /**
  22845. * Creates the VertexData for a tiled box
  22846. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22847. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22848. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22849. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22851. * @returns the VertexData of the box
  22852. */
  22853. static CreateTiledBox(options: {
  22854. pattern?: number;
  22855. width?: number;
  22856. height?: number;
  22857. depth?: number;
  22858. tileSize?: number;
  22859. tileWidth?: number;
  22860. tileHeight?: number;
  22861. alignHorizontal?: number;
  22862. alignVertical?: number;
  22863. faceUV?: Vector4[];
  22864. faceColors?: Color4[];
  22865. sideOrientation?: number;
  22866. }): VertexData;
  22867. /**
  22868. * Creates the VertexData for a tiled plane
  22869. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22870. * * pattern a limited pattern arrangement depending on the number
  22871. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22872. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22873. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22875. * * 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)
  22876. * * 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)
  22877. * @returns the VertexData of the tiled plane
  22878. */
  22879. static CreateTiledPlane(options: {
  22880. pattern?: number;
  22881. tileSize?: number;
  22882. tileWidth?: number;
  22883. tileHeight?: number;
  22884. size?: number;
  22885. width?: number;
  22886. height?: number;
  22887. alignHorizontal?: number;
  22888. alignVertical?: number;
  22889. sideOrientation?: number;
  22890. frontUVs?: Vector4;
  22891. backUVs?: Vector4;
  22892. }): VertexData;
  22893. /**
  22894. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22895. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22896. * * segments sets the number of horizontal strips optional, default 32
  22897. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22898. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22899. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22900. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22901. * * 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
  22902. * * 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
  22903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22904. * * 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)
  22905. * * 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)
  22906. * @returns the VertexData of the ellipsoid
  22907. */
  22908. static CreateSphere(options: {
  22909. segments?: number;
  22910. diameter?: number;
  22911. diameterX?: number;
  22912. diameterY?: number;
  22913. diameterZ?: number;
  22914. arc?: number;
  22915. slice?: number;
  22916. sideOrientation?: number;
  22917. frontUVs?: Vector4;
  22918. backUVs?: Vector4;
  22919. }): VertexData;
  22920. /**
  22921. * Creates the VertexData for a cylinder, cone or prism
  22922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22923. * * height sets the height (y direction) of the cylinder, optional, default 2
  22924. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22925. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22926. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22927. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22928. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22929. * * 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
  22930. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22931. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22932. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22933. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the cylinder, cone or prism
  22938. */
  22939. static CreateCylinder(options: {
  22940. height?: number;
  22941. diameterTop?: number;
  22942. diameterBottom?: number;
  22943. diameter?: number;
  22944. tessellation?: number;
  22945. subdivisions?: number;
  22946. arc?: number;
  22947. faceColors?: Color4[];
  22948. faceUV?: Vector4[];
  22949. hasRings?: boolean;
  22950. enclose?: boolean;
  22951. sideOrientation?: number;
  22952. frontUVs?: Vector4;
  22953. backUVs?: Vector4;
  22954. }): VertexData;
  22955. /**
  22956. * Creates the VertexData for a torus
  22957. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22958. * * diameter the diameter of the torus, optional default 1
  22959. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22960. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22962. * * 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)
  22963. * * 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)
  22964. * @returns the VertexData of the torus
  22965. */
  22966. static CreateTorus(options: {
  22967. diameter?: number;
  22968. thickness?: number;
  22969. tessellation?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData of the LineSystem
  22976. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22977. * - lines an array of lines, each line being an array of successive Vector3
  22978. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22979. * @returns the VertexData of the LineSystem
  22980. */
  22981. static CreateLineSystem(options: {
  22982. lines: Vector3[][];
  22983. colors?: Nullable<Color4[][]>;
  22984. }): VertexData;
  22985. /**
  22986. * Create the VertexData for a DashedLines
  22987. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22988. * - points an array successive Vector3
  22989. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22990. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22991. * - dashNb the intended total number of dashes, optional, default 200
  22992. * @returns the VertexData for the DashedLines
  22993. */
  22994. static CreateDashedLines(options: {
  22995. points: Vector3[];
  22996. dashSize?: number;
  22997. gapSize?: number;
  22998. dashNb?: number;
  22999. }): VertexData;
  23000. /**
  23001. * Creates the VertexData for a Ground
  23002. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23003. * - width the width (x direction) of the ground, optional, default 1
  23004. * - height the height (z direction) of the ground, optional, default 1
  23005. * - subdivisions the number of subdivisions per side, optional, default 1
  23006. * @returns the VertexData of the Ground
  23007. */
  23008. static CreateGround(options: {
  23009. width?: number;
  23010. height?: number;
  23011. subdivisions?: number;
  23012. subdivisionsX?: number;
  23013. subdivisionsY?: number;
  23014. }): VertexData;
  23015. /**
  23016. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23017. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23018. * * xmin the ground minimum X coordinate, optional, default -1
  23019. * * zmin the ground minimum Z coordinate, optional, default -1
  23020. * * xmax the ground maximum X coordinate, optional, default 1
  23021. * * zmax the ground maximum Z coordinate, optional, default 1
  23022. * * 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}
  23023. * * 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}
  23024. * @returns the VertexData of the TiledGround
  23025. */
  23026. static CreateTiledGround(options: {
  23027. xmin: number;
  23028. zmin: number;
  23029. xmax: number;
  23030. zmax: number;
  23031. subdivisions?: {
  23032. w: number;
  23033. h: number;
  23034. };
  23035. precision?: {
  23036. w: number;
  23037. h: number;
  23038. };
  23039. }): VertexData;
  23040. /**
  23041. * Creates the VertexData of the Ground designed from a heightmap
  23042. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23043. * * width the width (x direction) of the ground
  23044. * * height the height (z direction) of the ground
  23045. * * subdivisions the number of subdivisions per side
  23046. * * minHeight the minimum altitude on the ground, optional, default 0
  23047. * * maxHeight the maximum altitude on the ground, optional default 1
  23048. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23049. * * buffer the array holding the image color data
  23050. * * bufferWidth the width of image
  23051. * * bufferHeight the height of image
  23052. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23053. * @returns the VertexData of the Ground designed from a heightmap
  23054. */
  23055. static CreateGroundFromHeightMap(options: {
  23056. width: number;
  23057. height: number;
  23058. subdivisions: number;
  23059. minHeight: number;
  23060. maxHeight: number;
  23061. colorFilter: Color3;
  23062. buffer: Uint8Array;
  23063. bufferWidth: number;
  23064. bufferHeight: number;
  23065. alphaFilter: number;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData for a Plane
  23069. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23070. * * size sets the width and height of the plane to the value of size, optional default 1
  23071. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23072. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * * 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)
  23075. * * 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)
  23076. * @returns the VertexData of the box
  23077. */
  23078. static CreatePlane(options: {
  23079. size?: number;
  23080. width?: number;
  23081. height?: number;
  23082. sideOrientation?: number;
  23083. frontUVs?: Vector4;
  23084. backUVs?: Vector4;
  23085. }): VertexData;
  23086. /**
  23087. * Creates the VertexData of the Disc or regular Polygon
  23088. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23089. * * radius the radius of the disc, optional default 0.5
  23090. * * tessellation the number of polygon sides, optional, default 64
  23091. * * 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
  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 box
  23096. */
  23097. static CreateDisc(options: {
  23098. radius?: number;
  23099. tessellation?: number;
  23100. arc?: number;
  23101. sideOrientation?: number;
  23102. frontUVs?: Vector4;
  23103. backUVs?: Vector4;
  23104. }): VertexData;
  23105. /**
  23106. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23107. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23108. * @param polygon a mesh built from polygonTriangulation.build()
  23109. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23110. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23111. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23112. * @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)
  23113. * @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)
  23114. * @returns the VertexData of the Polygon
  23115. */
  23116. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23117. /**
  23118. * Creates the VertexData of the IcoSphere
  23119. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23120. * * radius the radius of the IcoSphere, optional default 1
  23121. * * radiusX allows stretching in the x direction, optional, default radius
  23122. * * radiusY allows stretching in the y direction, optional, default radius
  23123. * * radiusZ allows stretching in the z direction, optional, default radius
  23124. * * flat when true creates a flat shaded mesh, optional, default true
  23125. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23127. * * 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)
  23128. * * 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)
  23129. * @returns the VertexData of the IcoSphere
  23130. */
  23131. static CreateIcoSphere(options: {
  23132. radius?: number;
  23133. radiusX?: number;
  23134. radiusY?: number;
  23135. radiusZ?: number;
  23136. flat?: boolean;
  23137. subdivisions?: number;
  23138. sideOrientation?: number;
  23139. frontUVs?: Vector4;
  23140. backUVs?: Vector4;
  23141. }): VertexData;
  23142. /**
  23143. * Creates the VertexData for a Polyhedron
  23144. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23145. * * type provided types are:
  23146. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23147. * * 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)
  23148. * * size the size of the IcoSphere, optional default 1
  23149. * * sizeX allows stretching in the x direction, optional, default size
  23150. * * sizeY allows stretching in the y direction, optional, default size
  23151. * * sizeZ allows stretching in the z direction, optional, default size
  23152. * * 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
  23153. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23154. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23155. * * flat when true creates a flat shaded mesh, optional, default true
  23156. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23158. * * 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)
  23159. * * 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)
  23160. * @returns the VertexData of the Polyhedron
  23161. */
  23162. static CreatePolyhedron(options: {
  23163. type?: number;
  23164. size?: number;
  23165. sizeX?: number;
  23166. sizeY?: number;
  23167. sizeZ?: number;
  23168. custom?: any;
  23169. faceUV?: Vector4[];
  23170. faceColors?: Color4[];
  23171. flat?: boolean;
  23172. sideOrientation?: number;
  23173. frontUVs?: Vector4;
  23174. backUVs?: Vector4;
  23175. }): VertexData;
  23176. /**
  23177. * Creates the VertexData for a TorusKnot
  23178. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23179. * * radius the radius of the torus knot, optional, default 2
  23180. * * tube the thickness of the tube, optional, default 0.5
  23181. * * radialSegments the number of sides on each tube segments, optional, default 32
  23182. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23183. * * p the number of windings around the z axis, optional, default 2
  23184. * * q the number of windings around the x axis, optional, default 3
  23185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * * 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)
  23187. * * 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)
  23188. * @returns the VertexData of the Torus Knot
  23189. */
  23190. static CreateTorusKnot(options: {
  23191. radius?: number;
  23192. tube?: number;
  23193. radialSegments?: number;
  23194. tubularSegments?: number;
  23195. p?: number;
  23196. q?: number;
  23197. sideOrientation?: number;
  23198. frontUVs?: Vector4;
  23199. backUVs?: Vector4;
  23200. }): VertexData;
  23201. /**
  23202. * Compute normals for given positions and indices
  23203. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23204. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23205. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23206. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23207. * * facetNormals : optional array of facet normals (vector3)
  23208. * * facetPositions : optional array of facet positions (vector3)
  23209. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23210. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23211. * * bInfo : optional bounding info, required for facetPartitioning computation
  23212. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23213. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23214. * * useRightHandedSystem: optional boolean to for right handed system computation
  23215. * * depthSort : optional boolean to enable the facet depth sort computation
  23216. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23217. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23218. */
  23219. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23220. facetNormals?: any;
  23221. facetPositions?: any;
  23222. facetPartitioning?: any;
  23223. ratio?: number;
  23224. bInfo?: any;
  23225. bbSize?: Vector3;
  23226. subDiv?: any;
  23227. useRightHandedSystem?: boolean;
  23228. depthSort?: boolean;
  23229. distanceTo?: Vector3;
  23230. depthSortedFacets?: any;
  23231. }): void;
  23232. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23233. /**
  23234. * Applies VertexData created from the imported parameters to the geometry
  23235. * @param parsedVertexData the parsed data from an imported file
  23236. * @param geometry the geometry to apply the VertexData to
  23237. */
  23238. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23239. }
  23240. }
  23241. declare module BABYLON {
  23242. /**
  23243. * Class containing static functions to help procedurally build meshes
  23244. */
  23245. export class DiscBuilder {
  23246. /**
  23247. * Creates a plane polygonal mesh. By default, this is a disc
  23248. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23249. * * 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
  23250. * * 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
  23251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23252. * * 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
  23253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23254. * @param name defines the name of the mesh
  23255. * @param options defines the options used to create the mesh
  23256. * @param scene defines the hosting scene
  23257. * @returns the plane polygonal mesh
  23258. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23259. */
  23260. static CreateDisc(name: string, options: {
  23261. radius?: number;
  23262. tessellation?: number;
  23263. arc?: number;
  23264. updatable?: boolean;
  23265. sideOrientation?: number;
  23266. frontUVs?: Vector4;
  23267. backUVs?: Vector4;
  23268. }, scene?: Nullable<Scene>): Mesh;
  23269. }
  23270. }
  23271. declare module BABYLON {
  23272. /**
  23273. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23274. *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.
  23275. * The SPS is also a particle system. It provides some methods to manage the particles.
  23276. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23277. *
  23278. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23279. */
  23280. export class SolidParticleSystem implements IDisposable {
  23281. /**
  23282. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23283. * Example : var p = SPS.particles[i];
  23284. */
  23285. particles: SolidParticle[];
  23286. /**
  23287. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23288. */
  23289. nbParticles: number;
  23290. /**
  23291. * If the particles must ever face the camera (default false). Useful for planar particles.
  23292. */
  23293. billboard: boolean;
  23294. /**
  23295. * Recompute normals when adding a shape
  23296. */
  23297. recomputeNormals: boolean;
  23298. /**
  23299. * This a counter ofr your own usage. It's not set by any SPS functions.
  23300. */
  23301. counter: number;
  23302. /**
  23303. * The SPS name. This name is also given to the underlying mesh.
  23304. */
  23305. name: string;
  23306. /**
  23307. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23308. */
  23309. mesh: Mesh;
  23310. /**
  23311. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23312. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23313. */
  23314. vars: any;
  23315. /**
  23316. * This array is populated when the SPS is set as 'pickable'.
  23317. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23318. * Each element of this array is an object `{idx: int, faceId: int}`.
  23319. * `idx` is the picked particle index in the `SPS.particles` array
  23320. * `faceId` is the picked face index counted within this particle.
  23321. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23322. */
  23323. pickedParticles: {
  23324. idx: number;
  23325. faceId: number;
  23326. }[];
  23327. /**
  23328. * This array is populated when `enableDepthSort` is set to true.
  23329. * Each element of this array is an instance of the class DepthSortedParticle.
  23330. */
  23331. depthSortedParticles: DepthSortedParticle[];
  23332. /**
  23333. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23334. * @hidden
  23335. */ private _bSphereOnly: boolean;
  23336. /**
  23337. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23338. * @hidden
  23339. */ private _bSphereRadiusFactor: number;
  23340. private _scene;
  23341. private _positions;
  23342. private _indices;
  23343. private _normals;
  23344. private _colors;
  23345. private _uvs;
  23346. private _indices32;
  23347. private _positions32;
  23348. private _normals32;
  23349. private _fixedNormal32;
  23350. private _colors32;
  23351. private _uvs32;
  23352. private _index;
  23353. private _updatable;
  23354. private _pickable;
  23355. private _isVisibilityBoxLocked;
  23356. private _alwaysVisible;
  23357. private _depthSort;
  23358. private _shapeCounter;
  23359. private _copy;
  23360. private _color;
  23361. private _computeParticleColor;
  23362. private _computeParticleTexture;
  23363. private _computeParticleRotation;
  23364. private _computeParticleVertex;
  23365. private _computeBoundingBox;
  23366. private _depthSortParticles;
  23367. private _camera;
  23368. private _mustUnrotateFixedNormals;
  23369. private _particlesIntersect;
  23370. private _needs32Bits;
  23371. /**
  23372. * Creates a SPS (Solid Particle System) object.
  23373. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23374. * @param scene (Scene) is the scene in which the SPS is added.
  23375. * @param options defines the options of the sps e.g.
  23376. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23377. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23378. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23379. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23380. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23381. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23382. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23383. */
  23384. constructor(name: string, scene: Scene, options?: {
  23385. updatable?: boolean;
  23386. isPickable?: boolean;
  23387. enableDepthSort?: boolean;
  23388. particleIntersection?: boolean;
  23389. boundingSphereOnly?: boolean;
  23390. bSphereRadiusFactor?: number;
  23391. });
  23392. /**
  23393. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23394. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23395. * @returns the created mesh
  23396. */
  23397. buildMesh(): Mesh;
  23398. /**
  23399. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23400. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23401. * Thus the particles generated from `digest()` have their property `position` set yet.
  23402. * @param mesh ( Mesh ) is the mesh to be digested
  23403. * @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
  23404. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23405. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23406. * @returns the current SPS
  23407. */
  23408. digest(mesh: Mesh, options?: {
  23409. facetNb?: number;
  23410. number?: number;
  23411. delta?: number;
  23412. }): SolidParticleSystem;
  23413. private _unrotateFixedNormals;
  23414. private _resetCopy;
  23415. private _meshBuilder;
  23416. private _posToShape;
  23417. private _uvsToShapeUV;
  23418. private _addParticle;
  23419. /**
  23420. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23421. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23422. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23423. * @param nb (positive integer) the number of particles to be created from this model
  23424. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23425. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23426. * @returns the number of shapes in the system
  23427. */
  23428. addShape(mesh: Mesh, nb: number, options?: {
  23429. positionFunction?: any;
  23430. vertexFunction?: any;
  23431. }): number;
  23432. private _rebuildParticle;
  23433. /**
  23434. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23435. * @returns the SPS.
  23436. */
  23437. rebuildMesh(): SolidParticleSystem;
  23438. /**
  23439. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23440. * This method calls `updateParticle()` for each particle of the SPS.
  23441. * For an animated SPS, it is usually called within the render loop.
  23442. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23443. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23444. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23445. * @returns the SPS.
  23446. */
  23447. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23448. /**
  23449. * Disposes the SPS.
  23450. */
  23451. dispose(): void;
  23452. /**
  23453. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23454. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23455. * @returns the SPS.
  23456. */
  23457. refreshVisibleSize(): SolidParticleSystem;
  23458. /**
  23459. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23460. * @param size the size (float) of the visibility box
  23461. * note : this doesn't lock the SPS mesh bounding box.
  23462. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23463. */
  23464. setVisibilityBox(size: number): void;
  23465. /**
  23466. * Gets whether the SPS as always visible or not
  23467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23468. */
  23469. /**
  23470. * Sets the SPS as always visible or not
  23471. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23472. */
  23473. isAlwaysVisible: boolean;
  23474. /**
  23475. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23476. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23477. */
  23478. /**
  23479. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23481. */
  23482. isVisibilityBoxLocked: boolean;
  23483. /**
  23484. * Tells to `setParticles()` to compute the particle rotations or not.
  23485. * Default value : true. The SPS is faster when it's set to false.
  23486. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23487. */
  23488. /**
  23489. * Gets if `setParticles()` computes the particle rotations or not.
  23490. * Default value : true. The SPS is faster when it's set to false.
  23491. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23492. */
  23493. computeParticleRotation: boolean;
  23494. /**
  23495. * Tells to `setParticles()` to compute the particle colors or not.
  23496. * Default value : true. The SPS is faster when it's set to false.
  23497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23498. */
  23499. /**
  23500. * Gets if `setParticles()` computes the particle colors or not.
  23501. * Default value : true. The SPS is faster when it's set to false.
  23502. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23503. */
  23504. computeParticleColor: boolean;
  23505. /**
  23506. * Gets if `setParticles()` computes the particle textures or not.
  23507. * Default value : true. The SPS is faster when it's set to false.
  23508. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23509. */
  23510. computeParticleTexture: boolean;
  23511. /**
  23512. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23513. * Default value : false. The SPS is faster when it's set to false.
  23514. * Note : the particle custom vertex positions aren't stored values.
  23515. */
  23516. /**
  23517. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23518. * Default value : false. The SPS is faster when it's set to false.
  23519. * Note : the particle custom vertex positions aren't stored values.
  23520. */
  23521. computeParticleVertex: boolean;
  23522. /**
  23523. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23524. */
  23525. /**
  23526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23527. */
  23528. computeBoundingBox: boolean;
  23529. /**
  23530. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23531. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23532. * Default : `true`
  23533. */
  23534. /**
  23535. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23536. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23537. * Default : `true`
  23538. */
  23539. depthSortParticles: boolean;
  23540. /**
  23541. * This function does nothing. It may be overwritten to set all the particle first values.
  23542. * The SPS doesn't call this function, you may have to call it by your own.
  23543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23544. */
  23545. initParticles(): void;
  23546. /**
  23547. * This function does nothing. It may be overwritten to recycle a particle.
  23548. * The SPS doesn't call this function, you may have to call it by your own.
  23549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23550. * @param particle The particle to recycle
  23551. * @returns the recycled particle
  23552. */
  23553. recycleParticle(particle: SolidParticle): SolidParticle;
  23554. /**
  23555. * Updates a particle : this function should be overwritten by the user.
  23556. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23557. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23558. * @example : just set a particle position or velocity and recycle conditions
  23559. * @param particle The particle to update
  23560. * @returns the updated particle
  23561. */
  23562. updateParticle(particle: SolidParticle): SolidParticle;
  23563. /**
  23564. * Updates a vertex of a particle : it can be overwritten by the user.
  23565. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23566. * @param particle the current particle
  23567. * @param vertex the current index of the current particle
  23568. * @param pt the index of the current vertex in the particle shape
  23569. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23570. * @example : just set a vertex particle position
  23571. * @returns the updated vertex
  23572. */
  23573. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23574. /**
  23575. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23576. * This does nothing and may be overwritten by the user.
  23577. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23578. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23579. * @param update the boolean update value actually passed to setParticles()
  23580. */
  23581. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23582. /**
  23583. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23584. * This will be passed three parameters.
  23585. * This does nothing and may be overwritten by the user.
  23586. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23587. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23588. * @param update the boolean update value actually passed to setParticles()
  23589. */
  23590. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. /**
  23595. * Represents one particle of a solid particle system.
  23596. */
  23597. export class SolidParticle {
  23598. /**
  23599. * particle global index
  23600. */
  23601. idx: number;
  23602. /**
  23603. * The color of the particle
  23604. */
  23605. color: Nullable<Color4>;
  23606. /**
  23607. * The world space position of the particle.
  23608. */
  23609. position: Vector3;
  23610. /**
  23611. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23612. */
  23613. rotation: Vector3;
  23614. /**
  23615. * The world space rotation quaternion of the particle.
  23616. */
  23617. rotationQuaternion: Nullable<Quaternion>;
  23618. /**
  23619. * The scaling of the particle.
  23620. */
  23621. scaling: Vector3;
  23622. /**
  23623. * The uvs of the particle.
  23624. */
  23625. uvs: Vector4;
  23626. /**
  23627. * The current speed of the particle.
  23628. */
  23629. velocity: Vector3;
  23630. /**
  23631. * The pivot point in the particle local space.
  23632. */
  23633. pivot: Vector3;
  23634. /**
  23635. * Must the particle be translated from its pivot point in its local space ?
  23636. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23637. * Default : false
  23638. */
  23639. translateFromPivot: boolean;
  23640. /**
  23641. * Is the particle active or not ?
  23642. */
  23643. alive: boolean;
  23644. /**
  23645. * Is the particle visible or not ?
  23646. */
  23647. isVisible: boolean;
  23648. /**
  23649. * Index of this particle in the global "positions" array (Internal use)
  23650. * @hidden
  23651. */ private _pos: number;
  23652. /**
  23653. * @hidden Index of this particle in the global "indices" array (Internal use)
  23654. */ private _ind: number;
  23655. /**
  23656. * @hidden ModelShape of this particle (Internal use)
  23657. */ private _model: ModelShape;
  23658. /**
  23659. * ModelShape id of this particle
  23660. */
  23661. shapeId: number;
  23662. /**
  23663. * Index of the particle in its shape id (Internal use)
  23664. */
  23665. idxInShape: number;
  23666. /**
  23667. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23668. */ private _modelBoundingInfo: BoundingInfo;
  23669. /**
  23670. * @hidden Particle BoundingInfo object (Internal use)
  23671. */ private _boundingInfo: BoundingInfo;
  23672. /**
  23673. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23674. */ private _sps: SolidParticleSystem;
  23675. /**
  23676. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23677. */ private _stillInvisible: boolean;
  23678. /**
  23679. * @hidden Last computed particle rotation matrix
  23680. */ private _rotationMatrix: number[];
  23681. /**
  23682. * Parent particle Id, if any.
  23683. * Default null.
  23684. */
  23685. parentId: Nullable<number>;
  23686. /**
  23687. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23688. * The possible values are :
  23689. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23690. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23691. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23693. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23694. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23695. * */
  23696. cullingStrategy: number;
  23697. /**
  23698. * @hidden Internal global position in the SPS.
  23699. */ private _globalPosition: Vector3;
  23700. /**
  23701. * Creates a Solid Particle object.
  23702. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23703. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23704. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23705. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23706. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23707. * @param shapeId (integer) is the model shape identifier in the SPS.
  23708. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23709. * @param sps defines the sps it is associated to
  23710. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23711. */
  23712. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23713. /**
  23714. * Legacy support, changed scale to scaling
  23715. */
  23716. /**
  23717. * Legacy support, changed scale to scaling
  23718. */
  23719. scale: Vector3;
  23720. /**
  23721. * Legacy support, changed quaternion to rotationQuaternion
  23722. */
  23723. /**
  23724. * Legacy support, changed quaternion to rotationQuaternion
  23725. */
  23726. quaternion: Nullable<Quaternion>;
  23727. /**
  23728. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23729. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23730. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23731. * @returns true if it intersects
  23732. */
  23733. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23734. /**
  23735. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23736. * A particle is in the frustum if its bounding box intersects the frustum
  23737. * @param frustumPlanes defines the frustum to test
  23738. * @returns true if the particle is in the frustum planes
  23739. */
  23740. isInFrustum(frustumPlanes: Plane[]): boolean;
  23741. /**
  23742. * get the rotation matrix of the particle
  23743. * @hidden
  23744. */
  23745. getRotationMatrix(m: Matrix): void;
  23746. }
  23747. /**
  23748. * Represents the shape of the model used by one particle of a solid particle system.
  23749. * SPS internal tool, don't use it manually.
  23750. */
  23751. export class ModelShape {
  23752. /**
  23753. * The shape id
  23754. * @hidden
  23755. */
  23756. shapeID: number;
  23757. /**
  23758. * flat array of model positions (internal use)
  23759. * @hidden
  23760. */ private _shape: Vector3[];
  23761. /**
  23762. * flat array of model UVs (internal use)
  23763. * @hidden
  23764. */ private _shapeUV: number[];
  23765. /**
  23766. * length of the shape in the model indices array (internal use)
  23767. * @hidden
  23768. */ private _indicesLength: number;
  23769. /**
  23770. * Custom position function (internal use)
  23771. * @hidden
  23772. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23773. /**
  23774. * Custom vertex function (internal use)
  23775. * @hidden
  23776. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23777. /**
  23778. * 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.
  23779. * SPS internal tool, don't use it manually.
  23780. * @hidden
  23781. */
  23782. 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>);
  23783. }
  23784. /**
  23785. * Represents a Depth Sorted Particle in the solid particle system.
  23786. */
  23787. export class DepthSortedParticle {
  23788. /**
  23789. * Index of the particle in the "indices" array
  23790. */
  23791. ind: number;
  23792. /**
  23793. * Length of the particle shape in the "indices" array
  23794. */
  23795. indicesLength: number;
  23796. /**
  23797. * Squared distance from the particle to the camera
  23798. */
  23799. sqDistance: number;
  23800. }
  23801. }
  23802. declare module BABYLON {
  23803. /**
  23804. * @hidden
  23805. */
  23806. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /** @hidden */ private class _FacetDataStorage {
  23811. facetPositions: Vector3[];
  23812. facetNormals: Vector3[];
  23813. facetPartitioning: number[][];
  23814. facetNb: number;
  23815. partitioningSubdivisions: number;
  23816. partitioningBBoxRatio: number;
  23817. facetDataEnabled: boolean;
  23818. facetParameters: any;
  23819. bbSize: Vector3;
  23820. subDiv: {
  23821. max: number;
  23822. X: number;
  23823. Y: number;
  23824. Z: number;
  23825. };
  23826. facetDepthSort: boolean;
  23827. facetDepthSortEnabled: boolean;
  23828. depthSortedIndices: IndicesArray;
  23829. depthSortedFacets: {
  23830. ind: number;
  23831. sqDistance: number;
  23832. }[];
  23833. facetDepthSortFunction: (f1: {
  23834. ind: number;
  23835. sqDistance: number;
  23836. }, f2: {
  23837. ind: number;
  23838. sqDistance: number;
  23839. }) => number;
  23840. facetDepthSortFrom: Vector3;
  23841. facetDepthSortOrigin: Vector3;
  23842. invertedMatrix: Matrix;
  23843. }
  23844. /**
  23845. * @hidden
  23846. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  23847. }
  23848. /**
  23849. * Class used to store all common mesh properties
  23850. */
  23851. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23852. /** No occlusion */
  23853. static OCCLUSION_TYPE_NONE: number;
  23854. /** Occlusion set to optimisitic */
  23855. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23856. /** Occlusion set to strict */
  23857. static OCCLUSION_TYPE_STRICT: number;
  23858. /** Use an accurante occlusion algorithm */
  23859. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23860. /** Use a conservative occlusion algorithm */
  23861. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23862. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23863. * Test order :
  23864. * Is the bounding sphere outside the frustum ?
  23865. * If not, are the bounding box vertices outside the frustum ?
  23866. * It not, then the cullable object is in the frustum.
  23867. */
  23868. static readonly CULLINGSTRATEGY_STANDARD: number;
  23869. /** Culling strategy : Bounding Sphere Only.
  23870. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23871. * It's also less accurate than the standard because some not visible objects can still be selected.
  23872. * Test : is the bounding sphere outside the frustum ?
  23873. * If not, then the cullable object is in the frustum.
  23874. */
  23875. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23876. /** Culling strategy : Optimistic Inclusion.
  23877. * This in an inclusion test first, then the standard exclusion test.
  23878. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23879. * 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.
  23880. * Anyway, it's as accurate as the standard strategy.
  23881. * Test :
  23882. * Is the cullable object bounding sphere center in the frustum ?
  23883. * If not, apply the default culling strategy.
  23884. */
  23885. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23886. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23887. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23888. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23889. * 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.
  23890. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23891. * Test :
  23892. * Is the cullable object bounding sphere center in the frustum ?
  23893. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23894. */
  23895. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23896. /**
  23897. * No billboard
  23898. */
  23899. static readonly BILLBOARDMODE_NONE: number;
  23900. /** Billboard on X axis */
  23901. static readonly BILLBOARDMODE_X: number;
  23902. /** Billboard on Y axis */
  23903. static readonly BILLBOARDMODE_Y: number;
  23904. /** Billboard on Z axis */
  23905. static readonly BILLBOARDMODE_Z: number;
  23906. /** Billboard on all axes */
  23907. static readonly BILLBOARDMODE_ALL: number;
  23908. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  23909. /**
  23910. * The culling strategy to use to check whether the mesh must be rendered or not.
  23911. * This value can be changed at any time and will be used on the next render mesh selection.
  23912. * The possible values are :
  23913. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23914. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23915. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23916. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23917. * Please read each static variable documentation to get details about the culling process.
  23918. * */
  23919. cullingStrategy: number;
  23920. /**
  23921. * Gets the number of facets in the mesh
  23922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23923. */
  23924. readonly facetNb: number;
  23925. /**
  23926. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23928. */
  23929. partitioningSubdivisions: number;
  23930. /**
  23931. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23932. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23934. */
  23935. partitioningBBoxRatio: number;
  23936. /**
  23937. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23938. * Works only for updatable meshes.
  23939. * Doesn't work with multi-materials
  23940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23941. */
  23942. mustDepthSortFacets: boolean;
  23943. /**
  23944. * The location (Vector3) where the facet depth sort must be computed from.
  23945. * By default, the active camera position.
  23946. * Used only when facet depth sort is enabled
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23948. */
  23949. facetDepthSortFrom: Vector3;
  23950. /**
  23951. * gets a boolean indicating if facetData is enabled
  23952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23953. */
  23954. readonly isFacetDataEnabled: boolean;
  23955. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  23956. /**
  23957. * An event triggered when this mesh collides with another one
  23958. */
  23959. onCollideObservable: Observable<AbstractMesh>;
  23960. /** Set a function to call when this mesh collides with another one */
  23961. onCollide: () => void;
  23962. /**
  23963. * An event triggered when the collision's position changes
  23964. */
  23965. onCollisionPositionChangeObservable: Observable<Vector3>;
  23966. /** Set a function to call when the collision's position changes */
  23967. onCollisionPositionChange: () => void;
  23968. /**
  23969. * An event triggered when material is changed
  23970. */
  23971. onMaterialChangedObservable: Observable<AbstractMesh>;
  23972. /**
  23973. * Gets or sets the orientation for POV movement & rotation
  23974. */
  23975. definedFacingForward: boolean;
  23976. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  23977. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  23978. /**
  23979. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23980. */
  23981. /**
  23982. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23983. */
  23984. visibility: number;
  23985. /** Gets or sets the alpha index used to sort transparent meshes
  23986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23987. */
  23988. alphaIndex: number;
  23989. /**
  23990. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23991. */
  23992. isVisible: boolean;
  23993. /**
  23994. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23995. */
  23996. isPickable: boolean;
  23997. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23998. showSubMeshesBoundingBox: boolean;
  23999. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24000. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24001. */
  24002. isBlocker: boolean;
  24003. /**
  24004. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24005. */
  24006. enablePointerMoveEvents: boolean;
  24007. /**
  24008. * Specifies the rendering group id for this mesh (0 by default)
  24009. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24010. */
  24011. renderingGroupId: number;
  24012. private _material;
  24013. /** Gets or sets current material */
  24014. material: Nullable<Material>;
  24015. /**
  24016. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24017. * @see http://doc.babylonjs.com/babylon101/shadows
  24018. */
  24019. receiveShadows: boolean;
  24020. /** Defines color to use when rendering outline */
  24021. outlineColor: Color3;
  24022. /** Define width to use when rendering outline */
  24023. outlineWidth: number;
  24024. /** Defines color to use when rendering overlay */
  24025. overlayColor: Color3;
  24026. /** Defines alpha to use when rendering overlay */
  24027. overlayAlpha: number;
  24028. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24029. hasVertexAlpha: boolean;
  24030. /** 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) */
  24031. useVertexColors: boolean;
  24032. /**
  24033. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24034. */
  24035. computeBonesUsingShaders: boolean;
  24036. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24037. numBoneInfluencers: number;
  24038. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24039. applyFog: boolean;
  24040. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24041. useOctreeForRenderingSelection: boolean;
  24042. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24043. useOctreeForPicking: boolean;
  24044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24045. useOctreeForCollisions: boolean;
  24046. /**
  24047. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24048. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24049. */
  24050. layerMask: number;
  24051. /**
  24052. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24053. */
  24054. alwaysSelectAsActiveMesh: boolean;
  24055. /**
  24056. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24057. */
  24058. doNotSyncBoundingInfo: boolean;
  24059. /**
  24060. * Gets or sets the current action manager
  24061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24062. */
  24063. actionManager: Nullable<AbstractActionManager>;
  24064. private _meshCollisionData;
  24065. /**
  24066. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24068. */
  24069. ellipsoid: Vector3;
  24070. /**
  24071. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24073. */
  24074. ellipsoidOffset: Vector3;
  24075. /**
  24076. * Gets or sets a collision mask used to mask collisions (default is -1).
  24077. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24078. */
  24079. collisionMask: number;
  24080. /**
  24081. * Gets or sets the current collision group mask (-1 by default).
  24082. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24083. */
  24084. collisionGroup: number;
  24085. /**
  24086. * Defines edge width used when edgesRenderer is enabled
  24087. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24088. */
  24089. edgesWidth: number;
  24090. /**
  24091. * Defines edge color used when edgesRenderer is enabled
  24092. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24093. */
  24094. edgesColor: Color4;
  24095. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  24096. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  24097. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  24098. /** @hidden */ private _renderId: number;
  24099. /**
  24100. * Gets or sets the list of subMeshes
  24101. * @see http://doc.babylonjs.com/how_to/multi_materials
  24102. */
  24103. subMeshes: SubMesh[];
  24104. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  24105. /** @hidden */ private _unIndexed: boolean;
  24106. /** @hidden */ private _lightSources: Light[];
  24107. /** Gets the list of lights affecting that mesh */
  24108. readonly lightSources: Light[];
  24109. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24110. /** @hidden */ private _waitingData: {
  24111. lods: Nullable<any>;
  24112. actions: Nullable<any>;
  24113. freezeWorldMatrix: Nullable<boolean>;
  24114. };
  24115. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  24116. /**
  24117. * Gets or sets a skeleton to apply skining transformations
  24118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24119. */
  24120. skeleton: Nullable<Skeleton>;
  24121. /**
  24122. * An event triggered when the mesh is rebuilt.
  24123. */
  24124. onRebuildObservable: Observable<AbstractMesh>;
  24125. /**
  24126. * Creates a new AbstractMesh
  24127. * @param name defines the name of the mesh
  24128. * @param scene defines the hosting scene
  24129. */
  24130. constructor(name: string, scene?: Nullable<Scene>);
  24131. /**
  24132. * Returns the string "AbstractMesh"
  24133. * @returns "AbstractMesh"
  24134. */
  24135. getClassName(): string;
  24136. /**
  24137. * Gets a string representation of the current mesh
  24138. * @param fullDetails defines a boolean indicating if full details must be included
  24139. * @returns a string representation of the current mesh
  24140. */
  24141. toString(fullDetails?: boolean): string;
  24142. /**
  24143. * @hidden
  24144. */
  24145. protected _getEffectiveParent(): Nullable<Node>;
  24146. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24147. /** @hidden */ private _rebuild(): void;
  24148. /** @hidden */ private _resyncLightSources(): void;
  24149. /** @hidden */ private _resyncLighSource(light: Light): void;
  24150. /** @hidden */ private _unBindEffect(): void;
  24151. /** @hidden */ private _removeLightSource(light: Light): void;
  24152. private _markSubMeshesAsDirty;
  24153. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  24154. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  24155. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  24156. /**
  24157. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24158. */
  24159. scaling: Vector3;
  24160. /**
  24161. * Returns true if the mesh is blocked. Implemented by child classes
  24162. */
  24163. readonly isBlocked: boolean;
  24164. /**
  24165. * Returns the mesh itself by default. Implemented by child classes
  24166. * @param camera defines the camera to use to pick the right LOD level
  24167. * @returns the currentAbstractMesh
  24168. */
  24169. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24170. /**
  24171. * Returns 0 by default. Implemented by child classes
  24172. * @returns an integer
  24173. */
  24174. getTotalVertices(): number;
  24175. /**
  24176. * Returns a positive integer : the total number of indices in this mesh geometry.
  24177. * @returns the numner of indices or zero if the mesh has no geometry.
  24178. */
  24179. getTotalIndices(): number;
  24180. /**
  24181. * Returns null by default. Implemented by child classes
  24182. * @returns null
  24183. */
  24184. getIndices(): Nullable<IndicesArray>;
  24185. /**
  24186. * Returns the array of the requested vertex data kind. Implemented by child classes
  24187. * @param kind defines the vertex data kind to use
  24188. * @returns null
  24189. */
  24190. getVerticesData(kind: string): Nullable<FloatArray>;
  24191. /**
  24192. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24193. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24194. * Note that a new underlying VertexBuffer object is created each call.
  24195. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24196. * @param kind defines vertex data kind:
  24197. * * VertexBuffer.PositionKind
  24198. * * VertexBuffer.UVKind
  24199. * * VertexBuffer.UV2Kind
  24200. * * VertexBuffer.UV3Kind
  24201. * * VertexBuffer.UV4Kind
  24202. * * VertexBuffer.UV5Kind
  24203. * * VertexBuffer.UV6Kind
  24204. * * VertexBuffer.ColorKind
  24205. * * VertexBuffer.MatricesIndicesKind
  24206. * * VertexBuffer.MatricesIndicesExtraKind
  24207. * * VertexBuffer.MatricesWeightsKind
  24208. * * VertexBuffer.MatricesWeightsExtraKind
  24209. * @param data defines the data source
  24210. * @param updatable defines if the data must be flagged as updatable (or static)
  24211. * @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
  24212. * @returns the current mesh
  24213. */
  24214. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24215. /**
  24216. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24217. * If the mesh has no geometry, it is simply returned as it is.
  24218. * @param kind defines vertex data kind:
  24219. * * VertexBuffer.PositionKind
  24220. * * VertexBuffer.UVKind
  24221. * * VertexBuffer.UV2Kind
  24222. * * VertexBuffer.UV3Kind
  24223. * * VertexBuffer.UV4Kind
  24224. * * VertexBuffer.UV5Kind
  24225. * * VertexBuffer.UV6Kind
  24226. * * VertexBuffer.ColorKind
  24227. * * VertexBuffer.MatricesIndicesKind
  24228. * * VertexBuffer.MatricesIndicesExtraKind
  24229. * * VertexBuffer.MatricesWeightsKind
  24230. * * VertexBuffer.MatricesWeightsExtraKind
  24231. * @param data defines the data source
  24232. * @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
  24233. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24234. * @returns the current mesh
  24235. */
  24236. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24237. /**
  24238. * Sets the mesh indices,
  24239. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24240. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24241. * @param totalVertices Defines the total number of vertices
  24242. * @returns the current mesh
  24243. */
  24244. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24245. /**
  24246. * Gets a boolean indicating if specific vertex data is present
  24247. * @param kind defines the vertex data kind to use
  24248. * @returns true is data kind is present
  24249. */
  24250. isVerticesDataPresent(kind: string): boolean;
  24251. /**
  24252. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24253. * @returns a BoundingInfo
  24254. */
  24255. getBoundingInfo(): BoundingInfo;
  24256. /**
  24257. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24258. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24259. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24260. * @returns the current mesh
  24261. */
  24262. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24263. /**
  24264. * Overwrite the current bounding info
  24265. * @param boundingInfo defines the new bounding info
  24266. * @returns the current mesh
  24267. */
  24268. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24269. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24270. readonly useBones: boolean;
  24271. /** @hidden */ private _preActivate(): void;
  24272. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  24273. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  24274. /** @hidden */ private _postActivate(): void;
  24275. /** @hidden */ private _freeze(): void;
  24276. /** @hidden */ private _unFreeze(): void;
  24277. /**
  24278. * Gets the current world matrix
  24279. * @returns a Matrix
  24280. */
  24281. getWorldMatrix(): Matrix;
  24282. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24283. /**
  24284. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24285. */
  24286. readonly isAnInstance: boolean;
  24287. /**
  24288. * Perform relative position change from the point of view of behind the front of the mesh.
  24289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24290. * Supports definition of mesh facing forward or backward
  24291. * @param amountRight defines the distance on the right axis
  24292. * @param amountUp defines the distance on the up axis
  24293. * @param amountForward defines the distance on the forward axis
  24294. * @returns the current mesh
  24295. */
  24296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24297. /**
  24298. * Calculate relative position change from the point of view of behind the front of the mesh.
  24299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24300. * Supports definition of mesh facing forward or backward
  24301. * @param amountRight defines the distance on the right axis
  24302. * @param amountUp defines the distance on the up axis
  24303. * @param amountForward defines the distance on the forward axis
  24304. * @returns the new displacement vector
  24305. */
  24306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24307. /**
  24308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24309. * Supports definition of mesh facing forward or backward
  24310. * @param flipBack defines the flip
  24311. * @param twirlClockwise defines the twirl
  24312. * @param tiltRight defines the tilt
  24313. * @returns the current mesh
  24314. */
  24315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24316. /**
  24317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24318. * Supports definition of mesh facing forward or backward.
  24319. * @param flipBack defines the flip
  24320. * @param twirlClockwise defines the twirl
  24321. * @param tiltRight defines the tilt
  24322. * @returns the new rotation vector
  24323. */
  24324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24325. /**
  24326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24327. * This means the mesh underlying bounding box and sphere are recomputed.
  24328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24329. * @returns the current mesh
  24330. */
  24331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24332. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24333. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24334. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  24335. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24336. /** @hidden */
  24337. protected _afterComputeWorldMatrix(): void;
  24338. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24339. /**
  24340. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24341. * A mesh is in the frustum if its bounding box intersects the frustum
  24342. * @param frustumPlanes defines the frustum to test
  24343. * @returns true if the mesh is in the frustum planes
  24344. */
  24345. isInFrustum(frustumPlanes: Plane[]): boolean;
  24346. /**
  24347. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24348. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24349. * @param frustumPlanes defines the frustum to test
  24350. * @returns true if the mesh is completely in the frustum planes
  24351. */
  24352. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24353. /**
  24354. * True if the mesh intersects another mesh or a SolidParticle object
  24355. * @param mesh defines a target mesh or SolidParticle to test
  24356. * @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)
  24357. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24358. * @returns true if there is an intersection
  24359. */
  24360. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24361. /**
  24362. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24363. * @param point defines the point to test
  24364. * @returns true if there is an intersection
  24365. */
  24366. intersectsPoint(point: Vector3): boolean;
  24367. /**
  24368. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24370. */
  24371. checkCollisions: boolean;
  24372. /**
  24373. * Gets Collider object used to compute collisions (not physics)
  24374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24375. */
  24376. readonly collider: Nullable<Collider>;
  24377. /**
  24378. * Move the mesh using collision engine
  24379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24380. * @param displacement defines the requested displacement vector
  24381. * @returns the current mesh
  24382. */
  24383. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24384. private _onCollisionPositionChange;
  24385. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24386. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24387. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  24388. /** @hidden */ private _generatePointsArray(): boolean;
  24389. /**
  24390. * Checks if the passed Ray intersects with the mesh
  24391. * @param ray defines the ray to use
  24392. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24393. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24394. * @returns the picking info
  24395. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24396. */
  24397. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24398. /**
  24399. * Clones the current mesh
  24400. * @param name defines the mesh name
  24401. * @param newParent defines the new mesh parent
  24402. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24403. * @returns the new mesh
  24404. */
  24405. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24406. /**
  24407. * Disposes all the submeshes of the current meshnp
  24408. * @returns the current mesh
  24409. */
  24410. releaseSubMeshes(): AbstractMesh;
  24411. /**
  24412. * Releases resources associated with this abstract mesh.
  24413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24415. */
  24416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24417. /**
  24418. * Adds the passed mesh as a child to the current mesh
  24419. * @param mesh defines the child mesh
  24420. * @returns the current mesh
  24421. */
  24422. addChild(mesh: AbstractMesh): AbstractMesh;
  24423. /**
  24424. * Removes the passed mesh from the current mesh children list
  24425. * @param mesh defines the child mesh
  24426. * @returns the current mesh
  24427. */
  24428. removeChild(mesh: AbstractMesh): AbstractMesh;
  24429. /** @hidden */
  24430. private _initFacetData;
  24431. /**
  24432. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24433. * This method can be called within the render loop.
  24434. * 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
  24435. * @returns the current mesh
  24436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24437. */
  24438. updateFacetData(): AbstractMesh;
  24439. /**
  24440. * Returns the facetLocalNormals array.
  24441. * The normals are expressed in the mesh local spac
  24442. * @returns an array of Vector3
  24443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24444. */
  24445. getFacetLocalNormals(): Vector3[];
  24446. /**
  24447. * Returns the facetLocalPositions array.
  24448. * The facet positions are expressed in the mesh local space
  24449. * @returns an array of Vector3
  24450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24451. */
  24452. getFacetLocalPositions(): Vector3[];
  24453. /**
  24454. * Returns the facetLocalPartioning array
  24455. * @returns an array of array of numbers
  24456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24457. */
  24458. getFacetLocalPartitioning(): number[][];
  24459. /**
  24460. * Returns the i-th facet position in the world system.
  24461. * This method allocates a new Vector3 per call
  24462. * @param i defines the facet index
  24463. * @returns a new Vector3
  24464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24465. */
  24466. getFacetPosition(i: number): Vector3;
  24467. /**
  24468. * Sets the reference Vector3 with the i-th facet position in the world system
  24469. * @param i defines the facet index
  24470. * @param ref defines the target vector
  24471. * @returns the current mesh
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24473. */
  24474. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24475. /**
  24476. * Returns the i-th facet normal in the world system.
  24477. * This method allocates a new Vector3 per call
  24478. * @param i defines the facet index
  24479. * @returns a new Vector3
  24480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24481. */
  24482. getFacetNormal(i: number): Vector3;
  24483. /**
  24484. * Sets the reference Vector3 with the i-th facet normal in the world system
  24485. * @param i defines the facet index
  24486. * @param ref defines the target vector
  24487. * @returns the current mesh
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24489. */
  24490. getFacetNormalToRef(i: number, ref: Vector3): this;
  24491. /**
  24492. * 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)
  24493. * @param x defines x coordinate
  24494. * @param y defines y coordinate
  24495. * @param z defines z coordinate
  24496. * @returns the array of facet indexes
  24497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24498. */
  24499. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24500. /**
  24501. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24502. * @param projected sets as the (x,y,z) world projection on the facet
  24503. * @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
  24504. * @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
  24505. * @param x defines x coordinate
  24506. * @param y defines y coordinate
  24507. * @param z defines z coordinate
  24508. * @returns the face index if found (or null instead)
  24509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24510. */
  24511. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24512. /**
  24513. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24514. * @param projected sets as the (x,y,z) local projection on the facet
  24515. * @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
  24516. * @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
  24517. * @param x defines x coordinate
  24518. * @param y defines y coordinate
  24519. * @param z defines z coordinate
  24520. * @returns the face index if found (or null instead)
  24521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24522. */
  24523. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24524. /**
  24525. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24526. * @returns the parameters
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24528. */
  24529. getFacetDataParameters(): any;
  24530. /**
  24531. * Disables the feature FacetData and frees the related memory
  24532. * @returns the current mesh
  24533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24534. */
  24535. disableFacetData(): AbstractMesh;
  24536. /**
  24537. * Updates the AbstractMesh indices array
  24538. * @param indices defines the data source
  24539. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24540. * @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)
  24541. * @returns the current mesh
  24542. */
  24543. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24544. /**
  24545. * Creates new normals data for the mesh
  24546. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24547. * @returns the current mesh
  24548. */
  24549. createNormals(updatable: boolean): AbstractMesh;
  24550. /**
  24551. * Align the mesh with a normal
  24552. * @param normal defines the normal to use
  24553. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24554. * @returns the current mesh
  24555. */
  24556. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24557. /** @hidden */ private _checkOcclusionQuery(): boolean;
  24558. /**
  24559. * Disables the mesh edge rendering mode
  24560. * @returns the currentAbstractMesh
  24561. */
  24562. disableEdgesRendering(): AbstractMesh;
  24563. /**
  24564. * Enables the edge rendering mode on the mesh.
  24565. * This mode makes the mesh edges visible
  24566. * @param epsilon defines the maximal distance between two angles to detect a face
  24567. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24568. * @returns the currentAbstractMesh
  24569. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24570. */
  24571. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24572. }
  24573. }
  24574. declare module BABYLON {
  24575. /**
  24576. * Interface used to define ActionEvent
  24577. */
  24578. export interface IActionEvent {
  24579. /** The mesh or sprite that triggered the action */
  24580. source: any;
  24581. /** The X mouse cursor position at the time of the event */
  24582. pointerX: number;
  24583. /** The Y mouse cursor position at the time of the event */
  24584. pointerY: number;
  24585. /** The mesh that is currently pointed at (can be null) */
  24586. meshUnderPointer: Nullable<AbstractMesh>;
  24587. /** the original (browser) event that triggered the ActionEvent */
  24588. sourceEvent?: any;
  24589. /** additional data for the event */
  24590. additionalData?: any;
  24591. }
  24592. /**
  24593. * ActionEvent is the event being sent when an action is triggered.
  24594. */
  24595. export class ActionEvent implements IActionEvent {
  24596. /** The mesh or sprite that triggered the action */
  24597. source: any;
  24598. /** The X mouse cursor position at the time of the event */
  24599. pointerX: number;
  24600. /** The Y mouse cursor position at the time of the event */
  24601. pointerY: number;
  24602. /** The mesh that is currently pointed at (can be null) */
  24603. meshUnderPointer: Nullable<AbstractMesh>;
  24604. /** the original (browser) event that triggered the ActionEvent */
  24605. sourceEvent?: any;
  24606. /** additional data for the event */
  24607. additionalData?: any;
  24608. /**
  24609. * Creates a new ActionEvent
  24610. * @param source The mesh or sprite that triggered the action
  24611. * @param pointerX The X mouse cursor position at the time of the event
  24612. * @param pointerY The Y mouse cursor position at the time of the event
  24613. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24614. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24615. * @param additionalData additional data for the event
  24616. */
  24617. constructor(
  24618. /** The mesh or sprite that triggered the action */
  24619. source: any,
  24620. /** The X mouse cursor position at the time of the event */
  24621. pointerX: number,
  24622. /** The Y mouse cursor position at the time of the event */
  24623. pointerY: number,
  24624. /** The mesh that is currently pointed at (can be null) */
  24625. meshUnderPointer: Nullable<AbstractMesh>,
  24626. /** the original (browser) event that triggered the ActionEvent */
  24627. sourceEvent?: any,
  24628. /** additional data for the event */
  24629. additionalData?: any);
  24630. /**
  24631. * Helper function to auto-create an ActionEvent from a source mesh.
  24632. * @param source The source mesh that triggered the event
  24633. * @param evt The original (browser) event
  24634. * @param additionalData additional data for the event
  24635. * @returns the new ActionEvent
  24636. */
  24637. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24638. /**
  24639. * Helper function to auto-create an ActionEvent from a source sprite
  24640. * @param source The source sprite that triggered the event
  24641. * @param scene Scene associated with the sprite
  24642. * @param evt The original (browser) event
  24643. * @param additionalData additional data for the event
  24644. * @returns the new ActionEvent
  24645. */
  24646. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24647. /**
  24648. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24649. * @param scene the scene where the event occurred
  24650. * @param evt The original (browser) event
  24651. * @returns the new ActionEvent
  24652. */
  24653. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24654. /**
  24655. * Helper function to auto-create an ActionEvent from a primitive
  24656. * @param prim defines the target primitive
  24657. * @param pointerPos defines the pointer position
  24658. * @param evt The original (browser) event
  24659. * @param additionalData additional data for the event
  24660. * @returns the new ActionEvent
  24661. */
  24662. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24663. }
  24664. }
  24665. declare module BABYLON {
  24666. /**
  24667. * Abstract class used to decouple action Manager from scene and meshes.
  24668. * Do not instantiate.
  24669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24670. */
  24671. export abstract class AbstractActionManager implements IDisposable {
  24672. /** Gets the list of active triggers */
  24673. static Triggers: {
  24674. [key: string]: number;
  24675. };
  24676. /** Gets the cursor to use when hovering items */
  24677. hoverCursor: string;
  24678. /** Gets the list of actions */
  24679. actions: IAction[];
  24680. /**
  24681. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24682. */
  24683. isRecursive: boolean;
  24684. /**
  24685. * Releases all associated resources
  24686. */
  24687. abstract dispose(): void;
  24688. /**
  24689. * Does this action manager has pointer triggers
  24690. */
  24691. abstract readonly hasPointerTriggers: boolean;
  24692. /**
  24693. * Does this action manager has pick triggers
  24694. */
  24695. abstract readonly hasPickTriggers: boolean;
  24696. /**
  24697. * Process a specific trigger
  24698. * @param trigger defines the trigger to process
  24699. * @param evt defines the event details to be processed
  24700. */
  24701. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24702. /**
  24703. * Does this action manager handles actions of any of the given triggers
  24704. * @param triggers defines the triggers to be tested
  24705. * @return a boolean indicating whether one (or more) of the triggers is handled
  24706. */
  24707. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24708. /**
  24709. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24710. * speed.
  24711. * @param triggerA defines the trigger to be tested
  24712. * @param triggerB defines the trigger to be tested
  24713. * @return a boolean indicating whether one (or more) of the triggers is handled
  24714. */
  24715. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24716. /**
  24717. * Does this action manager handles actions of a given trigger
  24718. * @param trigger defines the trigger to be tested
  24719. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24720. * @return whether the trigger is handled
  24721. */
  24722. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24723. /**
  24724. * Serialize this manager to a JSON object
  24725. * @param name defines the property name to store this manager
  24726. * @returns a JSON representation of this manager
  24727. */
  24728. abstract serialize(name: string): any;
  24729. /**
  24730. * Registers an action to this action manager
  24731. * @param action defines the action to be registered
  24732. * @return the action amended (prepared) after registration
  24733. */
  24734. abstract registerAction(action: IAction): Nullable<IAction>;
  24735. /**
  24736. * Unregisters an action to this action manager
  24737. * @param action defines the action to be unregistered
  24738. * @return a boolean indicating whether the action has been unregistered
  24739. */
  24740. abstract unregisterAction(action: IAction): Boolean;
  24741. /**
  24742. * Does exist one action manager with at least one trigger
  24743. **/
  24744. static readonly HasTriggers: boolean;
  24745. /**
  24746. * Does exist one action manager with at least one pick trigger
  24747. **/
  24748. static readonly HasPickTriggers: boolean;
  24749. /**
  24750. * Does exist one action manager that handles actions of a given trigger
  24751. * @param trigger defines the trigger to be tested
  24752. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24753. **/
  24754. static HasSpecificTrigger(trigger: number): boolean;
  24755. }
  24756. }
  24757. declare module BABYLON {
  24758. /**
  24759. * Defines how a node can be built from a string name.
  24760. */
  24761. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24762. /**
  24763. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24764. */
  24765. export class Node implements IBehaviorAware<Node> {
  24766. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24767. private static _NodeConstructors;
  24768. /**
  24769. * Add a new node constructor
  24770. * @param type defines the type name of the node to construct
  24771. * @param constructorFunc defines the constructor function
  24772. */
  24773. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24774. /**
  24775. * Returns a node constructor based on type name
  24776. * @param type defines the type name
  24777. * @param name defines the new node name
  24778. * @param scene defines the hosting scene
  24779. * @param options defines optional options to transmit to constructors
  24780. * @returns the new constructor or null
  24781. */
  24782. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24783. /**
  24784. * Gets or sets the name of the node
  24785. */
  24786. name: string;
  24787. /**
  24788. * Gets or sets the id of the node
  24789. */
  24790. id: string;
  24791. /**
  24792. * Gets or sets the unique id of the node
  24793. */
  24794. uniqueId: number;
  24795. /**
  24796. * Gets or sets a string used to store user defined state for the node
  24797. */
  24798. state: string;
  24799. /**
  24800. * Gets or sets an object used to store user defined information for the node
  24801. */
  24802. metadata: any;
  24803. /**
  24804. * For internal use only. Please do not use.
  24805. */
  24806. reservedDataStore: any;
  24807. /**
  24808. * List of inspectable custom properties (used by the Inspector)
  24809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24810. */
  24811. inspectableCustomProperties: IInspectable[];
  24812. /**
  24813. * Gets or sets a boolean used to define if the node must be serialized
  24814. */
  24815. doNotSerialize: boolean;
  24816. /** @hidden */ private _isDisposed: boolean;
  24817. /**
  24818. * Gets a list of Animations associated with the node
  24819. */
  24820. animations: Animation[];
  24821. protected _ranges: {
  24822. [name: string]: Nullable<AnimationRange>;
  24823. };
  24824. /**
  24825. * Callback raised when the node is ready to be used
  24826. */
  24827. onReady: Nullable<(node: Node) => void>;
  24828. private _isEnabled;
  24829. private _isParentEnabled;
  24830. private _isReady;
  24831. /** @hidden */ private _currentRenderId: number;
  24832. private _parentUpdateId;
  24833. /** @hidden */ private _childUpdateId: number;
  24834. /** @hidden */ private _waitingParentId: Nullable<string>;
  24835. /** @hidden */ private _scene: Scene;
  24836. /** @hidden */ private _cache: any;
  24837. private _parentNode;
  24838. private _children;
  24839. /** @hidden */ private _worldMatrix: Matrix;
  24840. /** @hidden */ private _worldMatrixDeterminant: number;
  24841. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  24842. /** @hidden */
  24843. private _sceneRootNodesIndex;
  24844. /**
  24845. * Gets a boolean indicating if the node has been disposed
  24846. * @returns true if the node was disposed
  24847. */
  24848. isDisposed(): boolean;
  24849. /**
  24850. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24851. * @see https://doc.babylonjs.com/how_to/parenting
  24852. */
  24853. parent: Nullable<Node>;
  24854. private addToSceneRootNodes;
  24855. private removeFromSceneRootNodes;
  24856. private _animationPropertiesOverride;
  24857. /**
  24858. * Gets or sets the animation properties override
  24859. */
  24860. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24861. /**
  24862. * Gets a string idenfifying the name of the class
  24863. * @returns "Node" string
  24864. */
  24865. getClassName(): string;
  24866. /** @hidden */ protected readonly _isNode: boolean;
  24867. /**
  24868. * An event triggered when the mesh is disposed
  24869. */
  24870. onDisposeObservable: Observable<Node>;
  24871. private _onDisposeObserver;
  24872. /**
  24873. * Sets a callback that will be raised when the node will be disposed
  24874. */
  24875. onDispose: () => void;
  24876. /**
  24877. * Creates a new Node
  24878. * @param name the name and id to be given to this node
  24879. * @param scene the scene this node will be added to
  24880. * @param addToRootNodes the node will be added to scene.rootNodes
  24881. */
  24882. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24883. /**
  24884. * Gets the scene of the node
  24885. * @returns a scene
  24886. */
  24887. getScene(): Scene;
  24888. /**
  24889. * Gets the engine of the node
  24890. * @returns a Engine
  24891. */
  24892. getEngine(): Engine;
  24893. private _behaviors;
  24894. /**
  24895. * Attach a behavior to the node
  24896. * @see http://doc.babylonjs.com/features/behaviour
  24897. * @param behavior defines the behavior to attach
  24898. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24899. * @returns the current Node
  24900. */
  24901. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24902. /**
  24903. * Remove an attached behavior
  24904. * @see http://doc.babylonjs.com/features/behaviour
  24905. * @param behavior defines the behavior to attach
  24906. * @returns the current Node
  24907. */
  24908. removeBehavior(behavior: Behavior<Node>): Node;
  24909. /**
  24910. * Gets the list of attached behaviors
  24911. * @see http://doc.babylonjs.com/features/behaviour
  24912. */
  24913. readonly behaviors: Behavior<Node>[];
  24914. /**
  24915. * Gets an attached behavior by name
  24916. * @param name defines the name of the behavior to look for
  24917. * @see http://doc.babylonjs.com/features/behaviour
  24918. * @returns null if behavior was not found else the requested behavior
  24919. */
  24920. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24921. /**
  24922. * Returns the latest update of the World matrix
  24923. * @returns a Matrix
  24924. */
  24925. getWorldMatrix(): Matrix;
  24926. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24927. /**
  24928. * Returns directly the latest state of the mesh World matrix.
  24929. * A Matrix is returned.
  24930. */
  24931. readonly worldMatrixFromCache: Matrix;
  24932. /** @hidden */ private _initCache(): void;
  24933. /** @hidden */
  24934. updateCache(force?: boolean): void;
  24935. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24936. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24937. /** @hidden */ private _isSynchronized(): boolean;
  24938. /** @hidden */ private _markSyncedWithParent(): void;
  24939. /** @hidden */
  24940. isSynchronizedWithParent(): boolean;
  24941. /** @hidden */
  24942. isSynchronized(): boolean;
  24943. /**
  24944. * Is this node ready to be used/rendered
  24945. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24946. * @return true if the node is ready
  24947. */
  24948. isReady(completeCheck?: boolean): boolean;
  24949. /**
  24950. * Is this node enabled?
  24951. * 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
  24952. * @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
  24953. * @return whether this node (and its parent) is enabled
  24954. */
  24955. isEnabled(checkAncestors?: boolean): boolean;
  24956. /** @hidden */
  24957. protected _syncParentEnabledState(): void;
  24958. /**
  24959. * Set the enabled state of this node
  24960. * @param value defines the new enabled state
  24961. */
  24962. setEnabled(value: boolean): void;
  24963. /**
  24964. * Is this node a descendant of the given node?
  24965. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24966. * @param ancestor defines the parent node to inspect
  24967. * @returns a boolean indicating if this node is a descendant of the given node
  24968. */
  24969. isDescendantOf(ancestor: Node): boolean;
  24970. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24971. /**
  24972. * Will return all nodes that have this node as ascendant
  24973. * @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
  24974. * @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
  24975. * @return all children nodes of all types
  24976. */
  24977. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24978. /**
  24979. * Get all child-meshes of this node
  24980. * @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)
  24981. * @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
  24982. * @returns an array of AbstractMesh
  24983. */
  24984. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24985. /**
  24986. * Get all direct children of this node
  24987. * @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
  24988. * @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)
  24989. * @returns an array of Node
  24990. */
  24991. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24992. /** @hidden */ private _setReady(state: boolean): void;
  24993. /**
  24994. * Get an animation by name
  24995. * @param name defines the name of the animation to look for
  24996. * @returns null if not found else the requested animation
  24997. */
  24998. getAnimationByName(name: string): Nullable<Animation>;
  24999. /**
  25000. * Creates an animation range for this node
  25001. * @param name defines the name of the range
  25002. * @param from defines the starting key
  25003. * @param to defines the end key
  25004. */
  25005. createAnimationRange(name: string, from: number, to: number): void;
  25006. /**
  25007. * Delete a specific animation range
  25008. * @param name defines the name of the range to delete
  25009. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25010. */
  25011. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25012. /**
  25013. * Get an animation range by name
  25014. * @param name defines the name of the animation range to look for
  25015. * @returns null if not found else the requested animation range
  25016. */
  25017. getAnimationRange(name: string): Nullable<AnimationRange>;
  25018. /**
  25019. * Gets the list of all animation ranges defined on this node
  25020. * @returns an array
  25021. */
  25022. getAnimationRanges(): Nullable<AnimationRange>[];
  25023. /**
  25024. * Will start the animation sequence
  25025. * @param name defines the range frames for animation sequence
  25026. * @param loop defines if the animation should loop (false by default)
  25027. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25028. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25029. * @returns the object created for this animation. If range does not exist, it will return null
  25030. */
  25031. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25032. /**
  25033. * Serialize animation ranges into a JSON compatible object
  25034. * @returns serialization object
  25035. */
  25036. serializeAnimationRanges(): any;
  25037. /**
  25038. * Computes the world matrix of the node
  25039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25040. * @returns the world matrix
  25041. */
  25042. computeWorldMatrix(force?: boolean): Matrix;
  25043. /**
  25044. * Releases resources associated with this node.
  25045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25047. */
  25048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25049. /**
  25050. * Parse animation range data from a serialization object and store them into a given node
  25051. * @param node defines where to store the animation ranges
  25052. * @param parsedNode defines the serialization object to read data from
  25053. * @param scene defines the hosting scene
  25054. */
  25055. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25056. /**
  25057. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25058. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25059. * @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
  25060. * @returns the new bounding vectors
  25061. */
  25062. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25063. min: Vector3;
  25064. max: Vector3;
  25065. };
  25066. }
  25067. }
  25068. declare module BABYLON {
  25069. /**
  25070. * @hidden
  25071. */
  25072. export class _IAnimationState {
  25073. key: number;
  25074. repeatCount: number;
  25075. workValue?: any;
  25076. loopMode?: number;
  25077. offsetValue?: any;
  25078. highLimitValue?: any;
  25079. }
  25080. /**
  25081. * Class used to store any kind of animation
  25082. */
  25083. export class Animation {
  25084. /**Name of the animation */
  25085. name: string;
  25086. /**Property to animate */
  25087. targetProperty: string;
  25088. /**The frames per second of the animation */
  25089. framePerSecond: number;
  25090. /**The data type of the animation */
  25091. dataType: number;
  25092. /**The loop mode of the animation */
  25093. loopMode?: number | undefined;
  25094. /**Specifies if blending should be enabled */
  25095. enableBlending?: boolean | undefined;
  25096. /**
  25097. * Use matrix interpolation instead of using direct key value when animating matrices
  25098. */
  25099. static AllowMatricesInterpolation: boolean;
  25100. /**
  25101. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25102. */
  25103. static AllowMatrixDecomposeForInterpolation: boolean;
  25104. /**
  25105. * Stores the key frames of the animation
  25106. */
  25107. private _keys;
  25108. /**
  25109. * Stores the easing function of the animation
  25110. */
  25111. private _easingFunction;
  25112. /**
  25113. * @hidden Internal use only
  25114. */ private _runtimeAnimations: RuntimeAnimation[];
  25115. /**
  25116. * The set of event that will be linked to this animation
  25117. */
  25118. private _events;
  25119. /**
  25120. * Stores an array of target property paths
  25121. */
  25122. targetPropertyPath: string[];
  25123. /**
  25124. * Stores the blending speed of the animation
  25125. */
  25126. blendingSpeed: number;
  25127. /**
  25128. * Stores the animation ranges for the animation
  25129. */
  25130. private _ranges;
  25131. /**
  25132. * @hidden Internal use
  25133. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25134. /**
  25135. * Sets up an animation
  25136. * @param property The property to animate
  25137. * @param animationType The animation type to apply
  25138. * @param framePerSecond The frames per second of the animation
  25139. * @param easingFunction The easing function used in the animation
  25140. * @returns The created animation
  25141. */
  25142. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25143. /**
  25144. * Create and start an animation on a node
  25145. * @param name defines the name of the global animation that will be run on all nodes
  25146. * @param node defines the root node where the animation will take place
  25147. * @param targetProperty defines property to animate
  25148. * @param framePerSecond defines the number of frame per second yo use
  25149. * @param totalFrame defines the number of frames in total
  25150. * @param from defines the initial value
  25151. * @param to defines the final value
  25152. * @param loopMode defines which loop mode you want to use (off by default)
  25153. * @param easingFunction defines the easing function to use (linear by default)
  25154. * @param onAnimationEnd defines the callback to call when animation end
  25155. * @returns the animatable created for this animation
  25156. */
  25157. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25158. /**
  25159. * Create and start an animation on a node and its descendants
  25160. * @param name defines the name of the global animation that will be run on all nodes
  25161. * @param node defines the root node where the animation will take place
  25162. * @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
  25163. * @param targetProperty defines property to animate
  25164. * @param framePerSecond defines the number of frame per second to use
  25165. * @param totalFrame defines the number of frames in total
  25166. * @param from defines the initial value
  25167. * @param to defines the final value
  25168. * @param loopMode defines which loop mode you want to use (off by default)
  25169. * @param easingFunction defines the easing function to use (linear by default)
  25170. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25171. * @returns the list of animatables created for all nodes
  25172. * @example https://www.babylonjs-playground.com/#MH0VLI
  25173. */
  25174. 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[]>;
  25175. /**
  25176. * Creates a new animation, merges it with the existing animations and starts it
  25177. * @param name Name of the animation
  25178. * @param node Node which contains the scene that begins the animations
  25179. * @param targetProperty Specifies which property to animate
  25180. * @param framePerSecond The frames per second of the animation
  25181. * @param totalFrame The total number of frames
  25182. * @param from The frame at the beginning of the animation
  25183. * @param to The frame at the end of the animation
  25184. * @param loopMode Specifies the loop mode of the animation
  25185. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25186. * @param onAnimationEnd Callback to run once the animation is complete
  25187. * @returns Nullable animation
  25188. */
  25189. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25190. /**
  25191. * Transition property of an host to the target Value
  25192. * @param property The property to transition
  25193. * @param targetValue The target Value of the property
  25194. * @param host The object where the property to animate belongs
  25195. * @param scene Scene used to run the animation
  25196. * @param frameRate Framerate (in frame/s) to use
  25197. * @param transition The transition type we want to use
  25198. * @param duration The duration of the animation, in milliseconds
  25199. * @param onAnimationEnd Callback trigger at the end of the animation
  25200. * @returns Nullable animation
  25201. */
  25202. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25203. /**
  25204. * Return the array of runtime animations currently using this animation
  25205. */
  25206. readonly runtimeAnimations: RuntimeAnimation[];
  25207. /**
  25208. * Specifies if any of the runtime animations are currently running
  25209. */
  25210. readonly hasRunningRuntimeAnimations: boolean;
  25211. /**
  25212. * Initializes the animation
  25213. * @param name Name of the animation
  25214. * @param targetProperty Property to animate
  25215. * @param framePerSecond The frames per second of the animation
  25216. * @param dataType The data type of the animation
  25217. * @param loopMode The loop mode of the animation
  25218. * @param enableBlending Specifies if blending should be enabled
  25219. */
  25220. constructor(
  25221. /**Name of the animation */
  25222. name: string,
  25223. /**Property to animate */
  25224. targetProperty: string,
  25225. /**The frames per second of the animation */
  25226. framePerSecond: number,
  25227. /**The data type of the animation */
  25228. dataType: number,
  25229. /**The loop mode of the animation */
  25230. loopMode?: number | undefined,
  25231. /**Specifies if blending should be enabled */
  25232. enableBlending?: boolean | undefined);
  25233. /**
  25234. * Converts the animation to a string
  25235. * @param fullDetails support for multiple levels of logging within scene loading
  25236. * @returns String form of the animation
  25237. */
  25238. toString(fullDetails?: boolean): string;
  25239. /**
  25240. * Add an event to this animation
  25241. * @param event Event to add
  25242. */
  25243. addEvent(event: AnimationEvent): void;
  25244. /**
  25245. * Remove all events found at the given frame
  25246. * @param frame The frame to remove events from
  25247. */
  25248. removeEvents(frame: number): void;
  25249. /**
  25250. * Retrieves all the events from the animation
  25251. * @returns Events from the animation
  25252. */
  25253. getEvents(): AnimationEvent[];
  25254. /**
  25255. * Creates an animation range
  25256. * @param name Name of the animation range
  25257. * @param from Starting frame of the animation range
  25258. * @param to Ending frame of the animation
  25259. */
  25260. createRange(name: string, from: number, to: number): void;
  25261. /**
  25262. * Deletes an animation range by name
  25263. * @param name Name of the animation range to delete
  25264. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25265. */
  25266. deleteRange(name: string, deleteFrames?: boolean): void;
  25267. /**
  25268. * Gets the animation range by name, or null if not defined
  25269. * @param name Name of the animation range
  25270. * @returns Nullable animation range
  25271. */
  25272. getRange(name: string): Nullable<AnimationRange>;
  25273. /**
  25274. * Gets the key frames from the animation
  25275. * @returns The key frames of the animation
  25276. */
  25277. getKeys(): Array<IAnimationKey>;
  25278. /**
  25279. * Gets the highest frame rate of the animation
  25280. * @returns Highest frame rate of the animation
  25281. */
  25282. getHighestFrame(): number;
  25283. /**
  25284. * Gets the easing function of the animation
  25285. * @returns Easing function of the animation
  25286. */
  25287. getEasingFunction(): IEasingFunction;
  25288. /**
  25289. * Sets the easing function of the animation
  25290. * @param easingFunction A custom mathematical formula for animation
  25291. */
  25292. setEasingFunction(easingFunction: EasingFunction): void;
  25293. /**
  25294. * Interpolates a scalar linearly
  25295. * @param startValue Start value of the animation curve
  25296. * @param endValue End value of the animation curve
  25297. * @param gradient Scalar amount to interpolate
  25298. * @returns Interpolated scalar value
  25299. */
  25300. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25301. /**
  25302. * Interpolates a scalar cubically
  25303. * @param startValue Start value of the animation curve
  25304. * @param outTangent End tangent of the animation
  25305. * @param endValue End value of the animation curve
  25306. * @param inTangent Start tangent of the animation curve
  25307. * @param gradient Scalar amount to interpolate
  25308. * @returns Interpolated scalar value
  25309. */
  25310. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25311. /**
  25312. * Interpolates a quaternion using a spherical linear interpolation
  25313. * @param startValue Start value of the animation curve
  25314. * @param endValue End value of the animation curve
  25315. * @param gradient Scalar amount to interpolate
  25316. * @returns Interpolated quaternion value
  25317. */
  25318. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25319. /**
  25320. * Interpolates a quaternion cubically
  25321. * @param startValue Start value of the animation curve
  25322. * @param outTangent End tangent of the animation curve
  25323. * @param endValue End value of the animation curve
  25324. * @param inTangent Start tangent of the animation curve
  25325. * @param gradient Scalar amount to interpolate
  25326. * @returns Interpolated quaternion value
  25327. */
  25328. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25329. /**
  25330. * Interpolates a Vector3 linearl
  25331. * @param startValue Start value of the animation curve
  25332. * @param endValue End value of the animation curve
  25333. * @param gradient Scalar amount to interpolate
  25334. * @returns Interpolated scalar value
  25335. */
  25336. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25337. /**
  25338. * Interpolates a Vector3 cubically
  25339. * @param startValue Start value of the animation curve
  25340. * @param outTangent End tangent of the animation
  25341. * @param endValue End value of the animation curve
  25342. * @param inTangent Start tangent of the animation curve
  25343. * @param gradient Scalar amount to interpolate
  25344. * @returns InterpolatedVector3 value
  25345. */
  25346. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25347. /**
  25348. * Interpolates a Vector2 linearly
  25349. * @param startValue Start value of the animation curve
  25350. * @param endValue End value of the animation curve
  25351. * @param gradient Scalar amount to interpolate
  25352. * @returns Interpolated Vector2 value
  25353. */
  25354. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25355. /**
  25356. * Interpolates a Vector2 cubically
  25357. * @param startValue Start value of the animation curve
  25358. * @param outTangent End tangent of the animation
  25359. * @param endValue End value of the animation curve
  25360. * @param inTangent Start tangent of the animation curve
  25361. * @param gradient Scalar amount to interpolate
  25362. * @returns Interpolated Vector2 value
  25363. */
  25364. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25365. /**
  25366. * Interpolates a size linearly
  25367. * @param startValue Start value of the animation curve
  25368. * @param endValue End value of the animation curve
  25369. * @param gradient Scalar amount to interpolate
  25370. * @returns Interpolated Size value
  25371. */
  25372. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25373. /**
  25374. * Interpolates a Color3 linearly
  25375. * @param startValue Start value of the animation curve
  25376. * @param endValue End value of the animation curve
  25377. * @param gradient Scalar amount to interpolate
  25378. * @returns Interpolated Color3 value
  25379. */
  25380. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25381. /**
  25382. * @hidden Internal use only
  25383. */ private _getKeyValue(value: any): any;
  25384. /**
  25385. * @hidden Internal use only
  25386. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  25387. /**
  25388. * Defines the function to use to interpolate matrices
  25389. * @param startValue defines the start matrix
  25390. * @param endValue defines the end matrix
  25391. * @param gradient defines the gradient between both matrices
  25392. * @param result defines an optional target matrix where to store the interpolation
  25393. * @returns the interpolated matrix
  25394. */
  25395. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25396. /**
  25397. * Makes a copy of the animation
  25398. * @returns Cloned animation
  25399. */
  25400. clone(): Animation;
  25401. /**
  25402. * Sets the key frames of the animation
  25403. * @param values The animation key frames to set
  25404. */
  25405. setKeys(values: Array<IAnimationKey>): void;
  25406. /**
  25407. * Serializes the animation to an object
  25408. * @returns Serialized object
  25409. */
  25410. serialize(): any;
  25411. /**
  25412. * Float animation type
  25413. */
  25414. private static _ANIMATIONTYPE_FLOAT;
  25415. /**
  25416. * Vector3 animation type
  25417. */
  25418. private static _ANIMATIONTYPE_VECTOR3;
  25419. /**
  25420. * Quaternion animation type
  25421. */
  25422. private static _ANIMATIONTYPE_QUATERNION;
  25423. /**
  25424. * Matrix animation type
  25425. */
  25426. private static _ANIMATIONTYPE_MATRIX;
  25427. /**
  25428. * Color3 animation type
  25429. */
  25430. private static _ANIMATIONTYPE_COLOR3;
  25431. /**
  25432. * Vector2 animation type
  25433. */
  25434. private static _ANIMATIONTYPE_VECTOR2;
  25435. /**
  25436. * Size animation type
  25437. */
  25438. private static _ANIMATIONTYPE_SIZE;
  25439. /**
  25440. * Relative Loop Mode
  25441. */
  25442. private static _ANIMATIONLOOPMODE_RELATIVE;
  25443. /**
  25444. * Cycle Loop Mode
  25445. */
  25446. private static _ANIMATIONLOOPMODE_CYCLE;
  25447. /**
  25448. * Constant Loop Mode
  25449. */
  25450. private static _ANIMATIONLOOPMODE_CONSTANT;
  25451. /**
  25452. * Get the float animation type
  25453. */
  25454. static readonly ANIMATIONTYPE_FLOAT: number;
  25455. /**
  25456. * Get the Vector3 animation type
  25457. */
  25458. static readonly ANIMATIONTYPE_VECTOR3: number;
  25459. /**
  25460. * Get the Vector2 animation type
  25461. */
  25462. static readonly ANIMATIONTYPE_VECTOR2: number;
  25463. /**
  25464. * Get the Size animation type
  25465. */
  25466. static readonly ANIMATIONTYPE_SIZE: number;
  25467. /**
  25468. * Get the Quaternion animation type
  25469. */
  25470. static readonly ANIMATIONTYPE_QUATERNION: number;
  25471. /**
  25472. * Get the Matrix animation type
  25473. */
  25474. static readonly ANIMATIONTYPE_MATRIX: number;
  25475. /**
  25476. * Get the Color3 animation type
  25477. */
  25478. static readonly ANIMATIONTYPE_COLOR3: number;
  25479. /**
  25480. * Get the Relative Loop Mode
  25481. */
  25482. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25483. /**
  25484. * Get the Cycle Loop Mode
  25485. */
  25486. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25487. /**
  25488. * Get the Constant Loop Mode
  25489. */
  25490. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25491. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25492. /**
  25493. * Parses an animation object and creates an animation
  25494. * @param parsedAnimation Parsed animation object
  25495. * @returns Animation object
  25496. */
  25497. static Parse(parsedAnimation: any): Animation;
  25498. /**
  25499. * Appends the serialized animations from the source animations
  25500. * @param source Source containing the animations
  25501. * @param destination Target to store the animations
  25502. */
  25503. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25504. }
  25505. }
  25506. declare module BABYLON {
  25507. /**
  25508. * Base class of all the textures in babylon.
  25509. * It groups all the common properties the materials, post process, lights... might need
  25510. * in order to make a correct use of the texture.
  25511. */
  25512. export class BaseTexture implements IAnimatable {
  25513. /**
  25514. * Default anisotropic filtering level for the application.
  25515. * It is set to 4 as a good tradeoff between perf and quality.
  25516. */
  25517. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25518. /**
  25519. * Gets or sets the unique id of the texture
  25520. */
  25521. uniqueId: number;
  25522. /**
  25523. * Define the name of the texture.
  25524. */
  25525. name: string;
  25526. /**
  25527. * Gets or sets an object used to store user defined information.
  25528. */
  25529. metadata: any;
  25530. /**
  25531. * For internal use only. Please do not use.
  25532. */
  25533. reservedDataStore: any;
  25534. private _hasAlpha;
  25535. /**
  25536. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25537. */
  25538. hasAlpha: boolean;
  25539. /**
  25540. * Defines if the alpha value should be determined via the rgb values.
  25541. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25542. */
  25543. getAlphaFromRGB: boolean;
  25544. /**
  25545. * Intensity or strength of the texture.
  25546. * It is commonly used by materials to fine tune the intensity of the texture
  25547. */
  25548. level: number;
  25549. /**
  25550. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25551. * This is part of the texture as textures usually maps to one uv set.
  25552. */
  25553. coordinatesIndex: number;
  25554. private _coordinatesMode;
  25555. /**
  25556. * How a texture is mapped.
  25557. *
  25558. * | Value | Type | Description |
  25559. * | ----- | ----------------------------------- | ----------- |
  25560. * | 0 | EXPLICIT_MODE | |
  25561. * | 1 | SPHERICAL_MODE | |
  25562. * | 2 | PLANAR_MODE | |
  25563. * | 3 | CUBIC_MODE | |
  25564. * | 4 | PROJECTION_MODE | |
  25565. * | 5 | SKYBOX_MODE | |
  25566. * | 6 | INVCUBIC_MODE | |
  25567. * | 7 | EQUIRECTANGULAR_MODE | |
  25568. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25569. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25570. */
  25571. coordinatesMode: number;
  25572. /**
  25573. * | Value | Type | Description |
  25574. * | ----- | ------------------ | ----------- |
  25575. * | 0 | CLAMP_ADDRESSMODE | |
  25576. * | 1 | WRAP_ADDRESSMODE | |
  25577. * | 2 | MIRROR_ADDRESSMODE | |
  25578. */
  25579. wrapU: number;
  25580. /**
  25581. * | Value | Type | Description |
  25582. * | ----- | ------------------ | ----------- |
  25583. * | 0 | CLAMP_ADDRESSMODE | |
  25584. * | 1 | WRAP_ADDRESSMODE | |
  25585. * | 2 | MIRROR_ADDRESSMODE | |
  25586. */
  25587. wrapV: number;
  25588. /**
  25589. * | Value | Type | Description |
  25590. * | ----- | ------------------ | ----------- |
  25591. * | 0 | CLAMP_ADDRESSMODE | |
  25592. * | 1 | WRAP_ADDRESSMODE | |
  25593. * | 2 | MIRROR_ADDRESSMODE | |
  25594. */
  25595. wrapR: number;
  25596. /**
  25597. * With compliant hardware and browser (supporting anisotropic filtering)
  25598. * this defines the level of anisotropic filtering in the texture.
  25599. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25600. */
  25601. anisotropicFilteringLevel: number;
  25602. /**
  25603. * Define if the texture is a cube texture or if false a 2d texture.
  25604. */
  25605. isCube: boolean;
  25606. /**
  25607. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25608. */
  25609. is3D: boolean;
  25610. /**
  25611. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25612. * HDR texture are usually stored in linear space.
  25613. * This only impacts the PBR and Background materials
  25614. */
  25615. gammaSpace: boolean;
  25616. /**
  25617. * Gets whether or not the texture contains RGBD data.
  25618. */
  25619. readonly isRGBD: boolean;
  25620. /**
  25621. * Is Z inverted in the texture (useful in a cube texture).
  25622. */
  25623. invertZ: boolean;
  25624. /**
  25625. * Are mip maps generated for this texture or not.
  25626. */
  25627. readonly noMipmap: boolean;
  25628. /**
  25629. * @hidden
  25630. */
  25631. lodLevelInAlpha: boolean;
  25632. /**
  25633. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25634. */
  25635. lodGenerationOffset: number;
  25636. /**
  25637. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25638. */
  25639. lodGenerationScale: number;
  25640. /**
  25641. * Define if the texture is a render target.
  25642. */
  25643. isRenderTarget: boolean;
  25644. /**
  25645. * Define the unique id of the texture in the scene.
  25646. */
  25647. readonly uid: string;
  25648. /**
  25649. * Return a string representation of the texture.
  25650. * @returns the texture as a string
  25651. */
  25652. toString(): string;
  25653. /**
  25654. * Get the class name of the texture.
  25655. * @returns "BaseTexture"
  25656. */
  25657. getClassName(): string;
  25658. /**
  25659. * Define the list of animation attached to the texture.
  25660. */
  25661. animations: Animation[];
  25662. /**
  25663. * An event triggered when the texture is disposed.
  25664. */
  25665. onDisposeObservable: Observable<BaseTexture>;
  25666. private _onDisposeObserver;
  25667. /**
  25668. * Callback triggered when the texture has been disposed.
  25669. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25670. */
  25671. onDispose: () => void;
  25672. /**
  25673. * Define the current state of the loading sequence when in delayed load mode.
  25674. */
  25675. delayLoadState: number;
  25676. private _scene;
  25677. /** @hidden */ private _texture: Nullable<InternalTexture>;
  25678. private _uid;
  25679. /**
  25680. * Define if the texture is preventinga material to render or not.
  25681. * If not and the texture is not ready, the engine will use a default black texture instead.
  25682. */
  25683. readonly isBlocking: boolean;
  25684. /**
  25685. * Instantiates a new BaseTexture.
  25686. * Base class of all the textures in babylon.
  25687. * It groups all the common properties the materials, post process, lights... might need
  25688. * in order to make a correct use of the texture.
  25689. * @param scene Define the scene the texture blongs to
  25690. */
  25691. constructor(scene: Nullable<Scene>);
  25692. /**
  25693. * Get the scene the texture belongs to.
  25694. * @returns the scene or null if undefined
  25695. */
  25696. getScene(): Nullable<Scene>;
  25697. /**
  25698. * Get the texture transform matrix used to offset tile the texture for istance.
  25699. * @returns the transformation matrix
  25700. */
  25701. getTextureMatrix(): Matrix;
  25702. /**
  25703. * Get the texture reflection matrix used to rotate/transform the reflection.
  25704. * @returns the reflection matrix
  25705. */
  25706. getReflectionTextureMatrix(): Matrix;
  25707. /**
  25708. * Get the underlying lower level texture from Babylon.
  25709. * @returns the insternal texture
  25710. */
  25711. getInternalTexture(): Nullable<InternalTexture>;
  25712. /**
  25713. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25714. * @returns true if ready or not blocking
  25715. */
  25716. isReadyOrNotBlocking(): boolean;
  25717. /**
  25718. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25719. * @returns true if fully ready
  25720. */
  25721. isReady(): boolean;
  25722. private _cachedSize;
  25723. /**
  25724. * Get the size of the texture.
  25725. * @returns the texture size.
  25726. */
  25727. getSize(): ISize;
  25728. /**
  25729. * Get the base size of the texture.
  25730. * It can be different from the size if the texture has been resized for POT for instance
  25731. * @returns the base size
  25732. */
  25733. getBaseSize(): ISize;
  25734. /**
  25735. * Update the sampling mode of the texture.
  25736. * Default is Trilinear mode.
  25737. *
  25738. * | Value | Type | Description |
  25739. * | ----- | ------------------ | ----------- |
  25740. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25741. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25742. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25743. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25744. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25745. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25746. * | 7 | NEAREST_LINEAR | |
  25747. * | 8 | NEAREST_NEAREST | |
  25748. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25749. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25750. * | 11 | LINEAR_LINEAR | |
  25751. * | 12 | LINEAR_NEAREST | |
  25752. *
  25753. * > _mag_: magnification filter (close to the viewer)
  25754. * > _min_: minification filter (far from the viewer)
  25755. * > _mip_: filter used between mip map levels
  25756. *@param samplingMode Define the new sampling mode of the texture
  25757. */
  25758. updateSamplingMode(samplingMode: number): void;
  25759. /**
  25760. * Scales the texture if is `canRescale()`
  25761. * @param ratio the resize factor we want to use to rescale
  25762. */
  25763. scale(ratio: number): void;
  25764. /**
  25765. * Get if the texture can rescale.
  25766. */
  25767. readonly canRescale: boolean;
  25768. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25769. /** @hidden */ private _rebuild(): void;
  25770. /**
  25771. * Triggers the load sequence in delayed load mode.
  25772. */
  25773. delayLoad(): void;
  25774. /**
  25775. * Clones the texture.
  25776. * @returns the cloned texture
  25777. */
  25778. clone(): Nullable<BaseTexture>;
  25779. /**
  25780. * Get the texture underlying type (INT, FLOAT...)
  25781. */
  25782. readonly textureType: number;
  25783. /**
  25784. * Get the texture underlying format (RGB, RGBA...)
  25785. */
  25786. readonly textureFormat: number;
  25787. /**
  25788. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25789. * This will returns an RGBA array buffer containing either in values (0-255) or
  25790. * float values (0-1) depending of the underlying buffer type.
  25791. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25792. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25793. * @param buffer defines a user defined buffer to fill with data (can be null)
  25794. * @returns The Array buffer containing the pixels data.
  25795. */
  25796. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25797. /**
  25798. * Release and destroy the underlying lower level texture aka internalTexture.
  25799. */
  25800. releaseInternalTexture(): void;
  25801. /**
  25802. * Get the polynomial representation of the texture data.
  25803. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25804. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25805. */
  25806. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25807. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25808. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25809. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25810. /**
  25811. * Dispose the texture and release its associated resources.
  25812. */
  25813. dispose(): void;
  25814. /**
  25815. * Serialize the texture into a JSON representation that can be parsed later on.
  25816. * @returns the JSON representation of the texture
  25817. */
  25818. serialize(): any;
  25819. /**
  25820. * Helper function to be called back once a list of texture contains only ready textures.
  25821. * @param textures Define the list of textures to wait for
  25822. * @param callback Define the callback triggered once the entire list will be ready
  25823. */
  25824. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25825. }
  25826. }
  25827. declare module BABYLON {
  25828. /**
  25829. * Uniform buffer objects.
  25830. *
  25831. * Handles blocks of uniform on the GPU.
  25832. *
  25833. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25834. *
  25835. * For more information, please refer to :
  25836. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25837. */
  25838. export class UniformBuffer {
  25839. private _engine;
  25840. private _buffer;
  25841. private _data;
  25842. private _bufferData;
  25843. private _dynamic?;
  25844. private _uniformLocations;
  25845. private _uniformSizes;
  25846. private _uniformLocationPointer;
  25847. private _needSync;
  25848. private _noUBO;
  25849. private _currentEffect;
  25850. private static _MAX_UNIFORM_SIZE;
  25851. private static _tempBuffer;
  25852. /**
  25853. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25854. * This is dynamic to allow compat with webgl 1 and 2.
  25855. * You will need to pass the name of the uniform as well as the value.
  25856. */
  25857. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25858. /**
  25859. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25860. * This is dynamic to allow compat with webgl 1 and 2.
  25861. * You will need to pass the name of the uniform as well as the value.
  25862. */
  25863. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25864. /**
  25865. * Lambda to Update a single float in a uniform buffer.
  25866. * This is dynamic to allow compat with webgl 1 and 2.
  25867. * You will need to pass the name of the uniform as well as the value.
  25868. */
  25869. updateFloat: (name: string, x: number) => void;
  25870. /**
  25871. * Lambda to Update a vec2 of float in a uniform buffer.
  25872. * This is dynamic to allow compat with webgl 1 and 2.
  25873. * You will need to pass the name of the uniform as well as the value.
  25874. */
  25875. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25876. /**
  25877. * Lambda to Update a vec3 of float in a uniform buffer.
  25878. * This is dynamic to allow compat with webgl 1 and 2.
  25879. * You will need to pass the name of the uniform as well as the value.
  25880. */
  25881. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25882. /**
  25883. * Lambda to Update a vec4 of float in a uniform buffer.
  25884. * This is dynamic to allow compat with webgl 1 and 2.
  25885. * You will need to pass the name of the uniform as well as the value.
  25886. */
  25887. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25888. /**
  25889. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25890. * This is dynamic to allow compat with webgl 1 and 2.
  25891. * You will need to pass the name of the uniform as well as the value.
  25892. */
  25893. updateMatrix: (name: string, mat: Matrix) => void;
  25894. /**
  25895. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25896. * This is dynamic to allow compat with webgl 1 and 2.
  25897. * You will need to pass the name of the uniform as well as the value.
  25898. */
  25899. updateVector3: (name: string, vector: Vector3) => void;
  25900. /**
  25901. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25902. * This is dynamic to allow compat with webgl 1 and 2.
  25903. * You will need to pass the name of the uniform as well as the value.
  25904. */
  25905. updateVector4: (name: string, vector: Vector4) => void;
  25906. /**
  25907. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25908. * This is dynamic to allow compat with webgl 1 and 2.
  25909. * You will need to pass the name of the uniform as well as the value.
  25910. */
  25911. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25912. /**
  25913. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25914. * This is dynamic to allow compat with webgl 1 and 2.
  25915. * You will need to pass the name of the uniform as well as the value.
  25916. */
  25917. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25918. /**
  25919. * Instantiates a new Uniform buffer objects.
  25920. *
  25921. * Handles blocks of uniform on the GPU.
  25922. *
  25923. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25924. *
  25925. * For more information, please refer to :
  25926. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25927. * @param engine Define the engine the buffer is associated with
  25928. * @param data Define the data contained in the buffer
  25929. * @param dynamic Define if the buffer is updatable
  25930. */
  25931. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25932. /**
  25933. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25934. * or just falling back on setUniformXXX calls.
  25935. */
  25936. readonly useUbo: boolean;
  25937. /**
  25938. * Indicates if the WebGL underlying uniform buffer is in sync
  25939. * with the javascript cache data.
  25940. */
  25941. readonly isSync: boolean;
  25942. /**
  25943. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25944. * Also, a dynamic UniformBuffer will disable cache verification and always
  25945. * update the underlying WebGL uniform buffer to the GPU.
  25946. * @returns if Dynamic, otherwise false
  25947. */
  25948. isDynamic(): boolean;
  25949. /**
  25950. * The data cache on JS side.
  25951. * @returns the underlying data as a float array
  25952. */
  25953. getData(): Float32Array;
  25954. /**
  25955. * The underlying WebGL Uniform buffer.
  25956. * @returns the webgl buffer
  25957. */
  25958. getBuffer(): Nullable<DataBuffer>;
  25959. /**
  25960. * std140 layout specifies how to align data within an UBO structure.
  25961. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25962. * for specs.
  25963. */
  25964. private _fillAlignment;
  25965. /**
  25966. * Adds an uniform in the buffer.
  25967. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25968. * for the layout to be correct !
  25969. * @param name Name of the uniform, as used in the uniform block in the shader.
  25970. * @param size Data size, or data directly.
  25971. */
  25972. addUniform(name: string, size: number | number[]): void;
  25973. /**
  25974. * Adds a Matrix 4x4 to the uniform buffer.
  25975. * @param name Name of the uniform, as used in the uniform block in the shader.
  25976. * @param mat A 4x4 matrix.
  25977. */
  25978. addMatrix(name: string, mat: Matrix): void;
  25979. /**
  25980. * Adds a vec2 to the uniform buffer.
  25981. * @param name Name of the uniform, as used in the uniform block in the shader.
  25982. * @param x Define the x component value of the vec2
  25983. * @param y Define the y component value of the vec2
  25984. */
  25985. addFloat2(name: string, x: number, y: number): void;
  25986. /**
  25987. * Adds a vec3 to the uniform buffer.
  25988. * @param name Name of the uniform, as used in the uniform block in the shader.
  25989. * @param x Define the x component value of the vec3
  25990. * @param y Define the y component value of the vec3
  25991. * @param z Define the z component value of the vec3
  25992. */
  25993. addFloat3(name: string, x: number, y: number, z: number): void;
  25994. /**
  25995. * Adds a vec3 to the uniform buffer.
  25996. * @param name Name of the uniform, as used in the uniform block in the shader.
  25997. * @param color Define the vec3 from a Color
  25998. */
  25999. addColor3(name: string, color: Color3): void;
  26000. /**
  26001. * Adds a vec4 to the uniform buffer.
  26002. * @param name Name of the uniform, as used in the uniform block in the shader.
  26003. * @param color Define the rgb components from a Color
  26004. * @param alpha Define the a component of the vec4
  26005. */
  26006. addColor4(name: string, color: Color3, alpha: number): void;
  26007. /**
  26008. * Adds a vec3 to the uniform buffer.
  26009. * @param name Name of the uniform, as used in the uniform block in the shader.
  26010. * @param vector Define the vec3 components from a Vector
  26011. */
  26012. addVector3(name: string, vector: Vector3): void;
  26013. /**
  26014. * Adds a Matrix 3x3 to the uniform buffer.
  26015. * @param name Name of the uniform, as used in the uniform block in the shader.
  26016. */
  26017. addMatrix3x3(name: string): void;
  26018. /**
  26019. * Adds a Matrix 2x2 to the uniform buffer.
  26020. * @param name Name of the uniform, as used in the uniform block in the shader.
  26021. */
  26022. addMatrix2x2(name: string): void;
  26023. /**
  26024. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26025. */
  26026. create(): void;
  26027. /** @hidden */ private _rebuild(): void;
  26028. /**
  26029. * Updates the WebGL Uniform Buffer on the GPU.
  26030. * If the `dynamic` flag is set to true, no cache comparison is done.
  26031. * Otherwise, the buffer will be updated only if the cache differs.
  26032. */
  26033. update(): void;
  26034. /**
  26035. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26036. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26037. * @param data Define the flattened data
  26038. * @param size Define the size of the data.
  26039. */
  26040. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26041. private _updateMatrix3x3ForUniform;
  26042. private _updateMatrix3x3ForEffect;
  26043. private _updateMatrix2x2ForEffect;
  26044. private _updateMatrix2x2ForUniform;
  26045. private _updateFloatForEffect;
  26046. private _updateFloatForUniform;
  26047. private _updateFloat2ForEffect;
  26048. private _updateFloat2ForUniform;
  26049. private _updateFloat3ForEffect;
  26050. private _updateFloat3ForUniform;
  26051. private _updateFloat4ForEffect;
  26052. private _updateFloat4ForUniform;
  26053. private _updateMatrixForEffect;
  26054. private _updateMatrixForUniform;
  26055. private _updateVector3ForEffect;
  26056. private _updateVector3ForUniform;
  26057. private _updateVector4ForEffect;
  26058. private _updateVector4ForUniform;
  26059. private _updateColor3ForEffect;
  26060. private _updateColor3ForUniform;
  26061. private _updateColor4ForEffect;
  26062. private _updateColor4ForUniform;
  26063. /**
  26064. * Sets a sampler uniform on the effect.
  26065. * @param name Define the name of the sampler.
  26066. * @param texture Define the texture to set in the sampler
  26067. */
  26068. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26069. /**
  26070. * Directly updates the value of the uniform in the cache AND on the GPU.
  26071. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26072. * @param data Define the flattened data
  26073. */
  26074. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26075. /**
  26076. * Binds this uniform buffer to an effect.
  26077. * @param effect Define the effect to bind the buffer to
  26078. * @param name Name of the uniform block in the shader.
  26079. */
  26080. bindToEffect(effect: Effect, name: string): void;
  26081. /**
  26082. * Disposes the uniform buffer.
  26083. */
  26084. dispose(): void;
  26085. }
  26086. }
  26087. declare module BABYLON {
  26088. /**
  26089. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26091. */
  26092. export class Analyser {
  26093. /**
  26094. * Gets or sets the smoothing
  26095. * @ignorenaming
  26096. */
  26097. SMOOTHING: number;
  26098. /**
  26099. * Gets or sets the FFT table size
  26100. * @ignorenaming
  26101. */
  26102. FFT_SIZE: number;
  26103. /**
  26104. * Gets or sets the bar graph amplitude
  26105. * @ignorenaming
  26106. */
  26107. BARGRAPHAMPLITUDE: number;
  26108. /**
  26109. * Gets or sets the position of the debug canvas
  26110. * @ignorenaming
  26111. */
  26112. DEBUGCANVASPOS: {
  26113. x: number;
  26114. y: number;
  26115. };
  26116. /**
  26117. * Gets or sets the debug canvas size
  26118. * @ignorenaming
  26119. */
  26120. DEBUGCANVASSIZE: {
  26121. width: number;
  26122. height: number;
  26123. };
  26124. private _byteFreqs;
  26125. private _byteTime;
  26126. private _floatFreqs;
  26127. private _webAudioAnalyser;
  26128. private _debugCanvas;
  26129. private _debugCanvasContext;
  26130. private _scene;
  26131. private _registerFunc;
  26132. private _audioEngine;
  26133. /**
  26134. * Creates a new analyser
  26135. * @param scene defines hosting scene
  26136. */
  26137. constructor(scene: Scene);
  26138. /**
  26139. * Get the number of data values you will have to play with for the visualization
  26140. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26141. * @returns a number
  26142. */
  26143. getFrequencyBinCount(): number;
  26144. /**
  26145. * Gets the current frequency data as a byte array
  26146. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26147. * @returns a Uint8Array
  26148. */
  26149. getByteFrequencyData(): Uint8Array;
  26150. /**
  26151. * Gets the current waveform as a byte array
  26152. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26153. * @returns a Uint8Array
  26154. */
  26155. getByteTimeDomainData(): Uint8Array;
  26156. /**
  26157. * Gets the current frequency data as a float array
  26158. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26159. * @returns a Float32Array
  26160. */
  26161. getFloatFrequencyData(): Float32Array;
  26162. /**
  26163. * Renders the debug canvas
  26164. */
  26165. drawDebugCanvas(): void;
  26166. /**
  26167. * Stops rendering the debug canvas and removes it
  26168. */
  26169. stopDebugCanvas(): void;
  26170. /**
  26171. * Connects two audio nodes
  26172. * @param inputAudioNode defines first node to connect
  26173. * @param outputAudioNode defines second node to connect
  26174. */
  26175. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26176. /**
  26177. * Releases all associated resources
  26178. */
  26179. dispose(): void;
  26180. }
  26181. }
  26182. declare module BABYLON {
  26183. /**
  26184. * This represents an audio engine and it is responsible
  26185. * to play, synchronize and analyse sounds throughout the application.
  26186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26187. */
  26188. export interface IAudioEngine extends IDisposable {
  26189. /**
  26190. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26191. */
  26192. readonly canUseWebAudio: boolean;
  26193. /**
  26194. * Gets the current AudioContext if available.
  26195. */
  26196. readonly audioContext: Nullable<AudioContext>;
  26197. /**
  26198. * The master gain node defines the global audio volume of your audio engine.
  26199. */
  26200. readonly masterGain: GainNode;
  26201. /**
  26202. * Gets whether or not mp3 are supported by your browser.
  26203. */
  26204. readonly isMP3supported: boolean;
  26205. /**
  26206. * Gets whether or not ogg are supported by your browser.
  26207. */
  26208. readonly isOGGsupported: boolean;
  26209. /**
  26210. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26211. * @ignoreNaming
  26212. */
  26213. WarnedWebAudioUnsupported: boolean;
  26214. /**
  26215. * Defines if the audio engine relies on a custom unlocked button.
  26216. * In this case, the embedded button will not be displayed.
  26217. */
  26218. useCustomUnlockedButton: boolean;
  26219. /**
  26220. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26221. */
  26222. readonly unlocked: boolean;
  26223. /**
  26224. * Event raised when audio has been unlocked on the browser.
  26225. */
  26226. onAudioUnlockedObservable: Observable<AudioEngine>;
  26227. /**
  26228. * Event raised when audio has been locked on the browser.
  26229. */
  26230. onAudioLockedObservable: Observable<AudioEngine>;
  26231. /**
  26232. * Flags the audio engine in Locked state.
  26233. * This happens due to new browser policies preventing audio to autoplay.
  26234. */
  26235. lock(): void;
  26236. /**
  26237. * Unlocks the audio engine once a user action has been done on the dom.
  26238. * This is helpful to resume play once browser policies have been satisfied.
  26239. */
  26240. unlock(): void;
  26241. }
  26242. /**
  26243. * This represents the default audio engine used in babylon.
  26244. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26246. */
  26247. export class AudioEngine implements IAudioEngine {
  26248. private _audioContext;
  26249. private _audioContextInitialized;
  26250. private _muteButton;
  26251. private _hostElement;
  26252. /**
  26253. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26254. */
  26255. canUseWebAudio: boolean;
  26256. /**
  26257. * The master gain node defines the global audio volume of your audio engine.
  26258. */
  26259. masterGain: GainNode;
  26260. /**
  26261. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26262. * @ignoreNaming
  26263. */
  26264. WarnedWebAudioUnsupported: boolean;
  26265. /**
  26266. * Gets whether or not mp3 are supported by your browser.
  26267. */
  26268. isMP3supported: boolean;
  26269. /**
  26270. * Gets whether or not ogg are supported by your browser.
  26271. */
  26272. isOGGsupported: boolean;
  26273. /**
  26274. * Gets whether audio has been unlocked on the device.
  26275. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26276. * a user interaction has happened.
  26277. */
  26278. unlocked: boolean;
  26279. /**
  26280. * Defines if the audio engine relies on a custom unlocked button.
  26281. * In this case, the embedded button will not be displayed.
  26282. */
  26283. useCustomUnlockedButton: boolean;
  26284. /**
  26285. * Event raised when audio has been unlocked on the browser.
  26286. */
  26287. onAudioUnlockedObservable: Observable<AudioEngine>;
  26288. /**
  26289. * Event raised when audio has been locked on the browser.
  26290. */
  26291. onAudioLockedObservable: Observable<AudioEngine>;
  26292. /**
  26293. * Gets the current AudioContext if available.
  26294. */
  26295. readonly audioContext: Nullable<AudioContext>;
  26296. private _connectedAnalyser;
  26297. /**
  26298. * Instantiates a new audio engine.
  26299. *
  26300. * There should be only one per page as some browsers restrict the number
  26301. * of audio contexts you can create.
  26302. * @param hostElement defines the host element where to display the mute icon if necessary
  26303. */
  26304. constructor(hostElement?: Nullable<HTMLElement>);
  26305. /**
  26306. * Flags the audio engine in Locked state.
  26307. * This happens due to new browser policies preventing audio to autoplay.
  26308. */
  26309. lock(): void;
  26310. /**
  26311. * Unlocks the audio engine once a user action has been done on the dom.
  26312. * This is helpful to resume play once browser policies have been satisfied.
  26313. */
  26314. unlock(): void;
  26315. private _resumeAudioContext;
  26316. private _initializeAudioContext;
  26317. private _tryToRun;
  26318. private _triggerRunningState;
  26319. private _triggerSuspendedState;
  26320. private _displayMuteButton;
  26321. private _moveButtonToTopLeft;
  26322. private _onResize;
  26323. private _hideMuteButton;
  26324. /**
  26325. * Destroy and release the resources associated with the audio ccontext.
  26326. */
  26327. dispose(): void;
  26328. /**
  26329. * Gets the global volume sets on the master gain.
  26330. * @returns the global volume if set or -1 otherwise
  26331. */
  26332. getGlobalVolume(): number;
  26333. /**
  26334. * Sets the global volume of your experience (sets on the master gain).
  26335. * @param newVolume Defines the new global volume of the application
  26336. */
  26337. setGlobalVolume(newVolume: number): void;
  26338. /**
  26339. * Connect the audio engine to an audio analyser allowing some amazing
  26340. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26342. * @param analyser The analyser to connect to the engine
  26343. */
  26344. connectToAnalyser(analyser: Analyser): void;
  26345. }
  26346. }
  26347. declare module BABYLON {
  26348. /**
  26349. * Interface used to present a loading screen while loading a scene
  26350. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26351. */
  26352. export interface ILoadingScreen {
  26353. /**
  26354. * Function called to display the loading screen
  26355. */
  26356. displayLoadingUI: () => void;
  26357. /**
  26358. * Function called to hide the loading screen
  26359. */
  26360. hideLoadingUI: () => void;
  26361. /**
  26362. * Gets or sets the color to use for the background
  26363. */
  26364. loadingUIBackgroundColor: string;
  26365. /**
  26366. * Gets or sets the text to display while loading
  26367. */
  26368. loadingUIText: string;
  26369. }
  26370. /**
  26371. * Class used for the default loading screen
  26372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26373. */
  26374. export class DefaultLoadingScreen implements ILoadingScreen {
  26375. private _renderingCanvas;
  26376. private _loadingText;
  26377. private _loadingDivBackgroundColor;
  26378. private _loadingDiv;
  26379. private _loadingTextDiv;
  26380. /** Gets or sets the logo url to use for the default loading screen */
  26381. static DefaultLogoUrl: string;
  26382. /** Gets or sets the spinner url to use for the default loading screen */
  26383. static DefaultSpinnerUrl: string;
  26384. /**
  26385. * Creates a new default loading screen
  26386. * @param _renderingCanvas defines the canvas used to render the scene
  26387. * @param _loadingText defines the default text to display
  26388. * @param _loadingDivBackgroundColor defines the default background color
  26389. */
  26390. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26391. /**
  26392. * Function called to display the loading screen
  26393. */
  26394. displayLoadingUI(): void;
  26395. /**
  26396. * Function called to hide the loading screen
  26397. */
  26398. hideLoadingUI(): void;
  26399. /**
  26400. * Gets or sets the text to display while loading
  26401. */
  26402. loadingUIText: string;
  26403. /**
  26404. * Gets or sets the color to use for the background
  26405. */
  26406. loadingUIBackgroundColor: string;
  26407. private _resizeLoadingUI;
  26408. }
  26409. }
  26410. declare module BABYLON {
  26411. /** @hidden */
  26412. export class WebGLPipelineContext implements IPipelineContext {
  26413. engine: Engine;
  26414. program: Nullable<WebGLProgram>;
  26415. context?: WebGLRenderingContext;
  26416. vertexShader?: WebGLShader;
  26417. fragmentShader?: WebGLShader;
  26418. isParallelCompiled: boolean;
  26419. onCompiled?: () => void;
  26420. transformFeedback?: WebGLTransformFeedback | null;
  26421. readonly isAsync: boolean;
  26422. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26423. }
  26424. }
  26425. declare module BABYLON {
  26426. /** @hidden */
  26427. export class WebGLDataBuffer extends DataBuffer {
  26428. private _buffer;
  26429. constructor(resource: WebGLBuffer);
  26430. readonly underlyingResource: any;
  26431. }
  26432. }
  26433. declare module BABYLON {
  26434. /**
  26435. * Settings for finer control over video usage
  26436. */
  26437. export interface VideoTextureSettings {
  26438. /**
  26439. * Applies `autoplay` to video, if specified
  26440. */
  26441. autoPlay?: boolean;
  26442. /**
  26443. * Applies `loop` to video, if specified
  26444. */
  26445. loop?: boolean;
  26446. /**
  26447. * Automatically updates internal texture from video at every frame in the render loop
  26448. */
  26449. autoUpdateTexture: boolean;
  26450. /**
  26451. * Image src displayed during the video loading or until the user interacts with the video.
  26452. */
  26453. poster?: string;
  26454. }
  26455. /**
  26456. * If you want to display a video in your scene, this is the special texture for that.
  26457. * This special texture works similar to other textures, with the exception of a few parameters.
  26458. * @see https://doc.babylonjs.com/how_to/video_texture
  26459. */
  26460. export class VideoTexture extends Texture {
  26461. /**
  26462. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26463. */
  26464. readonly autoUpdateTexture: boolean;
  26465. /**
  26466. * The video instance used by the texture internally
  26467. */
  26468. readonly video: HTMLVideoElement;
  26469. private _onUserActionRequestedObservable;
  26470. /**
  26471. * Event triggerd when a dom action is required by the user to play the video.
  26472. * This happens due to recent changes in browser policies preventing video to auto start.
  26473. */
  26474. readonly onUserActionRequestedObservable: Observable<Texture>;
  26475. private _generateMipMaps;
  26476. private _engine;
  26477. private _stillImageCaptured;
  26478. private _displayingPosterTexture;
  26479. private _settings;
  26480. private _createInternalTextureOnEvent;
  26481. /**
  26482. * Creates a video texture.
  26483. * If you want to display a video in your scene, this is the special texture for that.
  26484. * This special texture works similar to other textures, with the exception of a few parameters.
  26485. * @see https://doc.babylonjs.com/how_to/video_texture
  26486. * @param name optional name, will detect from video source, if not defined
  26487. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26488. * @param scene is obviously the current scene.
  26489. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26490. * @param invertY is false by default but can be used to invert video on Y axis
  26491. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26492. * @param settings allows finer control over video usage
  26493. */
  26494. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26495. private _getName;
  26496. private _getVideo;
  26497. private _createInternalTexture;
  26498. private reset;
  26499. /**
  26500. * @hidden Internal method to initiate `update`.
  26501. */ private _rebuild(): void;
  26502. /**
  26503. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26504. */
  26505. update(): void;
  26506. /**
  26507. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26508. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26509. */
  26510. updateTexture(isVisible: boolean): void;
  26511. protected _updateInternalTexture: () => void;
  26512. /**
  26513. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26514. * @param url New url.
  26515. */
  26516. updateURL(url: string): void;
  26517. /**
  26518. * Dispose the texture and release its associated resources.
  26519. */
  26520. dispose(): void;
  26521. /**
  26522. * Creates a video texture straight from a stream.
  26523. * @param scene Define the scene the texture should be created in
  26524. * @param stream Define the stream the texture should be created from
  26525. * @returns The created video texture as a promise
  26526. */
  26527. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26528. /**
  26529. * Creates a video texture straight from your WebCam video feed.
  26530. * @param scene Define the scene the texture should be created in
  26531. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26532. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26533. * @returns The created video texture as a promise
  26534. */
  26535. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26536. minWidth: number;
  26537. maxWidth: number;
  26538. minHeight: number;
  26539. maxHeight: number;
  26540. deviceId: string;
  26541. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26542. /**
  26543. * Creates a video texture straight from your WebCam video feed.
  26544. * @param scene Define the scene the texture should be created in
  26545. * @param onReady Define a callback to triggered once the texture will be ready
  26546. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26547. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26548. */
  26549. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26550. minWidth: number;
  26551. maxWidth: number;
  26552. minHeight: number;
  26553. maxHeight: number;
  26554. deviceId: string;
  26555. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26556. }
  26557. }
  26558. declare module BABYLON {
  26559. /**
  26560. * Interface for attribute information associated with buffer instanciation
  26561. */
  26562. export class InstancingAttributeInfo {
  26563. /**
  26564. * Index/offset of the attribute in the vertex shader
  26565. */
  26566. index: number;
  26567. /**
  26568. * size of the attribute, 1, 2, 3 or 4
  26569. */
  26570. attributeSize: number;
  26571. /**
  26572. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26573. * default is FLOAT
  26574. */
  26575. attribyteType: number;
  26576. /**
  26577. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26578. */
  26579. normalized: boolean;
  26580. /**
  26581. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26582. */
  26583. offset: number;
  26584. /**
  26585. * Name of the GLSL attribute, for debugging purpose only
  26586. */
  26587. attributeName: string;
  26588. }
  26589. /**
  26590. * Define options used to create a depth texture
  26591. */
  26592. export class DepthTextureCreationOptions {
  26593. /** Specifies whether or not a stencil should be allocated in the texture */
  26594. generateStencil?: boolean;
  26595. /** Specifies whether or not bilinear filtering is enable on the texture */
  26596. bilinearFiltering?: boolean;
  26597. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26598. comparisonFunction?: number;
  26599. /** Specifies if the created texture is a cube texture */
  26600. isCube?: boolean;
  26601. }
  26602. /**
  26603. * Class used to describe the capabilities of the engine relatively to the current browser
  26604. */
  26605. export class EngineCapabilities {
  26606. /** Maximum textures units per fragment shader */
  26607. maxTexturesImageUnits: number;
  26608. /** Maximum texture units per vertex shader */
  26609. maxVertexTextureImageUnits: number;
  26610. /** Maximum textures units in the entire pipeline */
  26611. maxCombinedTexturesImageUnits: number;
  26612. /** Maximum texture size */
  26613. maxTextureSize: number;
  26614. /** Maximum cube texture size */
  26615. maxCubemapTextureSize: number;
  26616. /** Maximum render texture size */
  26617. maxRenderTextureSize: number;
  26618. /** Maximum number of vertex attributes */
  26619. maxVertexAttribs: number;
  26620. /** Maximum number of varyings */
  26621. maxVaryingVectors: number;
  26622. /** Maximum number of uniforms per vertex shader */
  26623. maxVertexUniformVectors: number;
  26624. /** Maximum number of uniforms per fragment shader */
  26625. maxFragmentUniformVectors: number;
  26626. /** Defines if standard derivates (dx/dy) are supported */
  26627. standardDerivatives: boolean;
  26628. /** Defines if s3tc texture compression is supported */
  26629. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26630. /** Defines if pvrtc texture compression is supported */
  26631. pvrtc: any;
  26632. /** Defines if etc1 texture compression is supported */
  26633. etc1: any;
  26634. /** Defines if etc2 texture compression is supported */
  26635. etc2: any;
  26636. /** Defines if astc texture compression is supported */
  26637. astc: any;
  26638. /** Defines if float textures are supported */
  26639. textureFloat: boolean;
  26640. /** Defines if vertex array objects are supported */
  26641. vertexArrayObject: boolean;
  26642. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26643. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26644. /** Gets the maximum level of anisotropy supported */
  26645. maxAnisotropy: number;
  26646. /** Defines if instancing is supported */
  26647. instancedArrays: boolean;
  26648. /** Defines if 32 bits indices are supported */
  26649. uintIndices: boolean;
  26650. /** Defines if high precision shaders are supported */
  26651. highPrecisionShaderSupported: boolean;
  26652. /** Defines if depth reading in the fragment shader is supported */
  26653. fragmentDepthSupported: boolean;
  26654. /** Defines if float texture linear filtering is supported*/
  26655. textureFloatLinearFiltering: boolean;
  26656. /** Defines if rendering to float textures is supported */
  26657. textureFloatRender: boolean;
  26658. /** Defines if half float textures are supported*/
  26659. textureHalfFloat: boolean;
  26660. /** Defines if half float texture linear filtering is supported*/
  26661. textureHalfFloatLinearFiltering: boolean;
  26662. /** Defines if rendering to half float textures is supported */
  26663. textureHalfFloatRender: boolean;
  26664. /** Defines if textureLOD shader command is supported */
  26665. textureLOD: boolean;
  26666. /** Defines if draw buffers extension is supported */
  26667. drawBuffersExtension: boolean;
  26668. /** Defines if depth textures are supported */
  26669. depthTextureExtension: boolean;
  26670. /** Defines if float color buffer are supported */
  26671. colorBufferFloat: boolean;
  26672. /** Gets disjoint timer query extension (null if not supported) */
  26673. timerQuery: EXT_disjoint_timer_query;
  26674. /** Defines if timestamp can be used with timer query */
  26675. canUseTimestampForTimerQuery: boolean;
  26676. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26677. multiview: any;
  26678. /** Function used to let the system compiles shaders in background */
  26679. parallelShaderCompile: {
  26680. COMPLETION_STATUS_KHR: number;
  26681. };
  26682. }
  26683. /** Interface defining initialization parameters for Engine class */
  26684. export interface EngineOptions extends WebGLContextAttributes {
  26685. /**
  26686. * Defines if the engine should no exceed a specified device ratio
  26687. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26688. */
  26689. limitDeviceRatio?: number;
  26690. /**
  26691. * Defines if webvr should be enabled automatically
  26692. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26693. */
  26694. autoEnableWebVR?: boolean;
  26695. /**
  26696. * Defines if webgl2 should be turned off even if supported
  26697. * @see http://doc.babylonjs.com/features/webgl2
  26698. */
  26699. disableWebGL2Support?: boolean;
  26700. /**
  26701. * Defines if webaudio should be initialized as well
  26702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26703. */
  26704. audioEngine?: boolean;
  26705. /**
  26706. * Defines if animations should run using a deterministic lock step
  26707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26708. */
  26709. deterministicLockstep?: boolean;
  26710. /** Defines the maximum steps to use with deterministic lock step mode */
  26711. lockstepMaxSteps?: number;
  26712. /**
  26713. * Defines that engine should ignore context lost events
  26714. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26715. */
  26716. doNotHandleContextLost?: boolean;
  26717. /**
  26718. * Defines that engine should ignore modifying touch action attribute and style
  26719. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26720. */
  26721. doNotHandleTouchAction?: boolean;
  26722. /**
  26723. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26724. */
  26725. useHighPrecisionFloats?: boolean;
  26726. }
  26727. /**
  26728. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26729. */
  26730. export class Engine {
  26731. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26732. static ExceptionList: ({
  26733. key: string;
  26734. capture: string;
  26735. captureConstraint: number;
  26736. targets: string[];
  26737. } | {
  26738. key: string;
  26739. capture: null;
  26740. captureConstraint: null;
  26741. targets: string[];
  26742. })[];
  26743. /** Gets the list of created engines */
  26744. static readonly Instances: Engine[];
  26745. /**
  26746. * Gets the latest created engine
  26747. */
  26748. static readonly LastCreatedEngine: Nullable<Engine>;
  26749. /**
  26750. * Gets the latest created scene
  26751. */
  26752. static readonly LastCreatedScene: Nullable<Scene>;
  26753. /**
  26754. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26755. * @param flag defines which part of the materials must be marked as dirty
  26756. * @param predicate defines a predicate used to filter which materials should be affected
  26757. */
  26758. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26759. /**
  26760. * Hidden
  26761. */ private static _TextureLoaders: IInternalTextureLoader[];
  26762. /** Defines that alpha blending is disabled */
  26763. static readonly ALPHA_DISABLE: number;
  26764. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26765. static readonly ALPHA_ADD: number;
  26766. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26767. static readonly ALPHA_COMBINE: number;
  26768. /** Defines that alpha blending to DEST - SRC * DEST */
  26769. static readonly ALPHA_SUBTRACT: number;
  26770. /** Defines that alpha blending to SRC * DEST */
  26771. static readonly ALPHA_MULTIPLY: number;
  26772. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26773. static readonly ALPHA_MAXIMIZED: number;
  26774. /** Defines that alpha blending to SRC + DEST */
  26775. static readonly ALPHA_ONEONE: number;
  26776. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26777. static readonly ALPHA_PREMULTIPLIED: number;
  26778. /**
  26779. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26780. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26781. */
  26782. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26783. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26784. static readonly ALPHA_INTERPOLATE: number;
  26785. /**
  26786. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26787. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26788. */
  26789. static readonly ALPHA_SCREENMODE: number;
  26790. /** Defines that the ressource is not delayed*/
  26791. static readonly DELAYLOADSTATE_NONE: number;
  26792. /** Defines that the ressource was successfully delay loaded */
  26793. static readonly DELAYLOADSTATE_LOADED: number;
  26794. /** Defines that the ressource is currently delay loading */
  26795. static readonly DELAYLOADSTATE_LOADING: number;
  26796. /** Defines that the ressource is delayed and has not started loading */
  26797. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26798. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26799. static readonly NEVER: number;
  26800. /** 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 */
  26801. static readonly ALWAYS: number;
  26802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26803. static readonly LESS: number;
  26804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26805. static readonly EQUAL: number;
  26806. /** 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 */
  26807. static readonly LEQUAL: number;
  26808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26809. static readonly GREATER: number;
  26810. /** 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 */
  26811. static readonly GEQUAL: number;
  26812. /** 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 */
  26813. static readonly NOTEQUAL: number;
  26814. /** Passed to stencilOperation to specify that stencil value must be kept */
  26815. static readonly KEEP: number;
  26816. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26817. static readonly REPLACE: number;
  26818. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26819. static readonly INCR: number;
  26820. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26821. static readonly DECR: number;
  26822. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26823. static readonly INVERT: number;
  26824. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26825. static readonly INCR_WRAP: number;
  26826. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26827. static readonly DECR_WRAP: number;
  26828. /** Texture is not repeating outside of 0..1 UVs */
  26829. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26830. /** Texture is repeating outside of 0..1 UVs */
  26831. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26832. /** Texture is repeating and mirrored */
  26833. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26834. /** ALPHA */
  26835. static readonly TEXTUREFORMAT_ALPHA: number;
  26836. /** LUMINANCE */
  26837. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26838. /** LUMINANCE_ALPHA */
  26839. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26840. /** RGB */
  26841. static readonly TEXTUREFORMAT_RGB: number;
  26842. /** RGBA */
  26843. static readonly TEXTUREFORMAT_RGBA: number;
  26844. /** RED */
  26845. static readonly TEXTUREFORMAT_RED: number;
  26846. /** RED (2nd reference) */
  26847. static readonly TEXTUREFORMAT_R: number;
  26848. /** RG */
  26849. static readonly TEXTUREFORMAT_RG: number;
  26850. /** RED_INTEGER */
  26851. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26852. /** RED_INTEGER (2nd reference) */
  26853. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26854. /** RG_INTEGER */
  26855. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26856. /** RGB_INTEGER */
  26857. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26858. /** RGBA_INTEGER */
  26859. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26860. /** UNSIGNED_BYTE */
  26861. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26862. /** UNSIGNED_BYTE (2nd reference) */
  26863. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26864. /** FLOAT */
  26865. static readonly TEXTURETYPE_FLOAT: number;
  26866. /** HALF_FLOAT */
  26867. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26868. /** BYTE */
  26869. static readonly TEXTURETYPE_BYTE: number;
  26870. /** SHORT */
  26871. static readonly TEXTURETYPE_SHORT: number;
  26872. /** UNSIGNED_SHORT */
  26873. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26874. /** INT */
  26875. static readonly TEXTURETYPE_INT: number;
  26876. /** UNSIGNED_INT */
  26877. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26878. /** UNSIGNED_SHORT_4_4_4_4 */
  26879. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26880. /** UNSIGNED_SHORT_5_5_5_1 */
  26881. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26882. /** UNSIGNED_SHORT_5_6_5 */
  26883. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26884. /** UNSIGNED_INT_2_10_10_10_REV */
  26885. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26886. /** UNSIGNED_INT_24_8 */
  26887. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26888. /** UNSIGNED_INT_10F_11F_11F_REV */
  26889. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26890. /** UNSIGNED_INT_5_9_9_9_REV */
  26891. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26892. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26893. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26894. /** nearest is mag = nearest and min = nearest and mip = linear */
  26895. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26897. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26898. /** Trilinear is mag = linear and min = linear and mip = linear */
  26899. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26900. /** nearest is mag = nearest and min = nearest and mip = linear */
  26901. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26902. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26903. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26904. /** Trilinear is mag = linear and min = linear and mip = linear */
  26905. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26906. /** mag = nearest and min = nearest and mip = nearest */
  26907. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26908. /** mag = nearest and min = linear and mip = nearest */
  26909. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26910. /** mag = nearest and min = linear and mip = linear */
  26911. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26912. /** mag = nearest and min = linear and mip = none */
  26913. static readonly TEXTURE_NEAREST_LINEAR: number;
  26914. /** mag = nearest and min = nearest and mip = none */
  26915. static readonly TEXTURE_NEAREST_NEAREST: number;
  26916. /** mag = linear and min = nearest and mip = nearest */
  26917. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26918. /** mag = linear and min = nearest and mip = linear */
  26919. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26920. /** mag = linear and min = linear and mip = none */
  26921. static readonly TEXTURE_LINEAR_LINEAR: number;
  26922. /** mag = linear and min = nearest and mip = none */
  26923. static readonly TEXTURE_LINEAR_NEAREST: number;
  26924. /** Explicit coordinates mode */
  26925. static readonly TEXTURE_EXPLICIT_MODE: number;
  26926. /** Spherical coordinates mode */
  26927. static readonly TEXTURE_SPHERICAL_MODE: number;
  26928. /** Planar coordinates mode */
  26929. static readonly TEXTURE_PLANAR_MODE: number;
  26930. /** Cubic coordinates mode */
  26931. static readonly TEXTURE_CUBIC_MODE: number;
  26932. /** Projection coordinates mode */
  26933. static readonly TEXTURE_PROJECTION_MODE: number;
  26934. /** Skybox coordinates mode */
  26935. static readonly TEXTURE_SKYBOX_MODE: number;
  26936. /** Inverse Cubic coordinates mode */
  26937. static readonly TEXTURE_INVCUBIC_MODE: number;
  26938. /** Equirectangular coordinates mode */
  26939. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26940. /** Equirectangular Fixed coordinates mode */
  26941. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26942. /** Equirectangular Fixed Mirrored coordinates mode */
  26943. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26944. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26945. static readonly SCALEMODE_FLOOR: number;
  26946. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26947. static readonly SCALEMODE_NEAREST: number;
  26948. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26949. static readonly SCALEMODE_CEILING: number;
  26950. /**
  26951. * Returns the current npm package of the sdk
  26952. */
  26953. static readonly NpmPackage: string;
  26954. /**
  26955. * Returns the current version of the framework
  26956. */
  26957. static readonly Version: string;
  26958. /**
  26959. * Returns a string describing the current engine
  26960. */
  26961. readonly description: string;
  26962. /**
  26963. * Gets or sets the epsilon value used by collision engine
  26964. */
  26965. static CollisionsEpsilon: number;
  26966. /**
  26967. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26968. */
  26969. static ShadersRepository: string;
  26970. /**
  26971. * Method called to create the default loading screen.
  26972. * This can be overriden in your own app.
  26973. * @param canvas The rendering canvas element
  26974. * @returns The loading screen
  26975. */
  26976. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26977. /**
  26978. * Method called to create the default rescale post process on each engine.
  26979. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26980. /**
  26981. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26982. */
  26983. forcePOTTextures: boolean;
  26984. /**
  26985. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26986. */
  26987. isFullscreen: boolean;
  26988. /**
  26989. * Gets a boolean indicating if the pointer is currently locked
  26990. */
  26991. isPointerLock: boolean;
  26992. /**
  26993. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26994. */
  26995. cullBackFaces: boolean;
  26996. /**
  26997. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26998. */
  26999. renderEvenInBackground: boolean;
  27000. /**
  27001. * Gets or sets a boolean indicating that cache can be kept between frames
  27002. */
  27003. preventCacheWipeBetweenFrames: boolean;
  27004. /**
  27005. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27006. **/
  27007. enableOfflineSupport: boolean;
  27008. /**
  27009. * 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)
  27010. **/
  27011. disableManifestCheck: boolean;
  27012. /**
  27013. * Gets the list of created scenes
  27014. */
  27015. scenes: Scene[];
  27016. /**
  27017. * Event raised when a new scene is created
  27018. */
  27019. onNewSceneAddedObservable: Observable<Scene>;
  27020. /**
  27021. * Gets the list of created postprocesses
  27022. */
  27023. postProcesses: PostProcess[];
  27024. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27025. validateShaderPrograms: boolean;
  27026. /**
  27027. * Observable event triggered each time the rendering canvas is resized
  27028. */
  27029. onResizeObservable: Observable<Engine>;
  27030. /**
  27031. * Observable event triggered each time the canvas loses focus
  27032. */
  27033. onCanvasBlurObservable: Observable<Engine>;
  27034. /**
  27035. * Observable event triggered each time the canvas gains focus
  27036. */
  27037. onCanvasFocusObservable: Observable<Engine>;
  27038. /**
  27039. * Observable event triggered each time the canvas receives pointerout event
  27040. */
  27041. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27042. /**
  27043. * Observable event triggered before each texture is initialized
  27044. */
  27045. onBeforeTextureInitObservable: Observable<Texture>;
  27046. /**
  27047. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27048. */
  27049. disableUniformBuffers: boolean;
  27050. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  27051. /**
  27052. * Gets a boolean indicating that the engine supports uniform buffers
  27053. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27054. */
  27055. readonly supportsUniformBuffers: boolean;
  27056. /**
  27057. * Observable raised when the engine begins a new frame
  27058. */
  27059. onBeginFrameObservable: Observable<Engine>;
  27060. /**
  27061. * If set, will be used to request the next animation frame for the render loop
  27062. */
  27063. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27064. /**
  27065. * Observable raised when the engine ends the current frame
  27066. */
  27067. onEndFrameObservable: Observable<Engine>;
  27068. /**
  27069. * Observable raised when the engine is about to compile a shader
  27070. */
  27071. onBeforeShaderCompilationObservable: Observable<Engine>;
  27072. /**
  27073. * Observable raised when the engine has jsut compiled a shader
  27074. */
  27075. onAfterShaderCompilationObservable: Observable<Engine>;
  27076. /** @hidden */ private _gl: WebGLRenderingContext;
  27077. private _renderingCanvas;
  27078. private _windowIsBackground;
  27079. private _webGLVersion;
  27080. protected _highPrecisionShadersAllowed: boolean;
  27081. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27082. /**
  27083. * Gets a boolean indicating that only power of 2 textures are supported
  27084. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27085. */
  27086. readonly needPOTTextures: boolean;
  27087. /** @hidden */ private _badOS: boolean;
  27088. /** @hidden */ private _badDesktopOS: boolean;
  27089. /**
  27090. * Gets the audio engine
  27091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27092. * @ignorenaming
  27093. */
  27094. static audioEngine: IAudioEngine;
  27095. /**
  27096. * Default AudioEngine factory responsible of creating the Audio Engine.
  27097. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27098. */
  27099. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27100. /**
  27101. * Default offline support factory responsible of creating a tool used to store data locally.
  27102. * By default, this will create a Database object if the workload has been embedded.
  27103. */
  27104. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27105. private _onFocus;
  27106. private _onBlur;
  27107. private _onCanvasPointerOut;
  27108. private _onCanvasBlur;
  27109. private _onCanvasFocus;
  27110. private _onFullscreenChange;
  27111. private _onPointerLockChange;
  27112. private _hardwareScalingLevel;
  27113. /** @hidden */ private _caps: EngineCapabilities;
  27114. private _pointerLockRequested;
  27115. private _isStencilEnable;
  27116. private _colorWrite;
  27117. private _loadingScreen;
  27118. /** @hidden */ private _drawCalls: PerfCounter;
  27119. private _glVersion;
  27120. private _glRenderer;
  27121. private _glVendor;
  27122. private _videoTextureSupported;
  27123. private _renderingQueueLaunched;
  27124. private _activeRenderLoops;
  27125. private _deterministicLockstep;
  27126. private _lockstepMaxSteps;
  27127. /**
  27128. * Observable signaled when a context lost event is raised
  27129. */
  27130. onContextLostObservable: Observable<Engine>;
  27131. /**
  27132. * Observable signaled when a context restored event is raised
  27133. */
  27134. onContextRestoredObservable: Observable<Engine>;
  27135. private _onContextLost;
  27136. private _onContextRestored;
  27137. private _contextWasLost;
  27138. /** @hidden */ private _doNotHandleContextLost: boolean;
  27139. /**
  27140. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27142. */
  27143. doNotHandleContextLost: boolean;
  27144. private _performanceMonitor;
  27145. private _fps;
  27146. private _deltaTime;
  27147. /**
  27148. * Turn this value on if you want to pause FPS computation when in background
  27149. */
  27150. disablePerformanceMonitorInBackground: boolean;
  27151. /**
  27152. * Gets the performance monitor attached to this engine
  27153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27154. */
  27155. readonly performanceMonitor: PerformanceMonitor;
  27156. /**
  27157. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27158. */
  27159. disableVertexArrayObjects: boolean;
  27160. /** @hidden */
  27161. protected _depthCullingState: _DepthCullingState;
  27162. /** @hidden */
  27163. protected _stencilState: _StencilState;
  27164. /** @hidden */
  27165. protected _alphaState: _AlphaState;
  27166. /** @hidden */
  27167. protected _alphaMode: number;
  27168. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  27169. /** @hidden */
  27170. protected _activeChannel: number;
  27171. private _currentTextureChannel;
  27172. /** @hidden */
  27173. protected _boundTexturesCache: {
  27174. [key: string]: Nullable<InternalTexture>;
  27175. };
  27176. /** @hidden */
  27177. protected _currentEffect: Nullable<Effect>;
  27178. /** @hidden */
  27179. protected _currentProgram: Nullable<WebGLProgram>;
  27180. private _compiledEffects;
  27181. private _vertexAttribArraysEnabled;
  27182. /** @hidden */
  27183. protected _cachedViewport: Nullable<Viewport>;
  27184. private _cachedVertexArrayObject;
  27185. /** @hidden */
  27186. protected _cachedVertexBuffers: any;
  27187. /** @hidden */
  27188. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27189. /** @hidden */
  27190. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27191. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  27192. private _uintIndicesCurrentlySet;
  27193. private _currentBoundBuffer;
  27194. /** @hidden */
  27195. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27196. private _currentBufferPointers;
  27197. private _currentInstanceLocations;
  27198. private _currentInstanceBuffers;
  27199. private _textureUnits;
  27200. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27201. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27202. private _rescalePostProcess;
  27203. private _dummyFramebuffer;
  27204. private _externalData;
  27205. /** @hidden */ private _bindedRenderFunction: any;
  27206. private _vaoRecordInProgress;
  27207. private _mustWipeVertexAttributes;
  27208. private _emptyTexture;
  27209. private _emptyCubeTexture;
  27210. private _emptyTexture3D;
  27211. /** @hidden */ private _frameHandler: number;
  27212. private _nextFreeTextureSlots;
  27213. private _maxSimultaneousTextures;
  27214. private _activeRequests;
  27215. private _texturesSupported;
  27216. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  27217. /**
  27218. * Gets the list of texture formats supported
  27219. */
  27220. readonly texturesSupported: Array<string>;
  27221. /**
  27222. * Gets the list of texture formats in use
  27223. */
  27224. readonly textureFormatInUse: Nullable<string>;
  27225. /**
  27226. * Gets the current viewport
  27227. */
  27228. readonly currentViewport: Nullable<Viewport>;
  27229. /**
  27230. * Gets the default empty texture
  27231. */
  27232. readonly emptyTexture: InternalTexture;
  27233. /**
  27234. * Gets the default empty 3D texture
  27235. */
  27236. readonly emptyTexture3D: InternalTexture;
  27237. /**
  27238. * Gets the default empty cube texture
  27239. */
  27240. readonly emptyCubeTexture: InternalTexture;
  27241. /**
  27242. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27243. */
  27244. readonly premultipliedAlpha: boolean;
  27245. /**
  27246. * Creates a new engine
  27247. * @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
  27248. * @param antialias defines enable antialiasing (default: false)
  27249. * @param options defines further options to be sent to the getContext() function
  27250. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27251. */
  27252. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27253. /**
  27254. * Initializes a webVR display and starts listening to display change events
  27255. * The onVRDisplayChangedObservable will be notified upon these changes
  27256. * @returns The onVRDisplayChangedObservable
  27257. */
  27258. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27259. /** @hidden */ private _prepareVRComponent(): void;
  27260. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27261. /** @hidden */ private _submitVRFrame(): void;
  27262. /**
  27263. * Call this function to leave webVR mode
  27264. * Will do nothing if webVR is not supported or if there is no webVR device
  27265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27266. */
  27267. disableVR(): void;
  27268. /**
  27269. * Gets a boolean indicating that the system is in VR mode and is presenting
  27270. * @returns true if VR mode is engaged
  27271. */
  27272. isVRPresenting(): boolean;
  27273. /** @hidden */ private _requestVRFrame(): void;
  27274. private _disableTouchAction;
  27275. private _rebuildInternalTextures;
  27276. private _rebuildEffects;
  27277. /**
  27278. * Gets a boolean indicating if all created effects are ready
  27279. * @returns true if all effects are ready
  27280. */
  27281. areAllEffectsReady(): boolean;
  27282. private _rebuildBuffers;
  27283. private _initGLContext;
  27284. /**
  27285. * Gets version of the current webGL context
  27286. */
  27287. readonly webGLVersion: number;
  27288. /**
  27289. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27290. */
  27291. readonly isStencilEnable: boolean;
  27292. /** @hidden */ private _prepareWorkingCanvas(): void;
  27293. /**
  27294. * Reset the texture cache to empty state
  27295. */
  27296. resetTextureCache(): void;
  27297. /**
  27298. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27300. * @returns true if engine is in deterministic lock step mode
  27301. */
  27302. isDeterministicLockStep(): boolean;
  27303. /**
  27304. * Gets the max steps when engine is running in deterministic lock step
  27305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27306. * @returns the max steps
  27307. */
  27308. getLockstepMaxSteps(): number;
  27309. /**
  27310. * Gets an object containing information about the current webGL context
  27311. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27312. */
  27313. getGlInfo(): {
  27314. vendor: string;
  27315. renderer: string;
  27316. version: string;
  27317. };
  27318. /**
  27319. * Gets current aspect ratio
  27320. * @param camera defines the camera to use to get the aspect ratio
  27321. * @param useScreen defines if screen size must be used (or the current render target if any)
  27322. * @returns a number defining the aspect ratio
  27323. */
  27324. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27325. /**
  27326. * Gets current screen aspect ratio
  27327. * @returns a number defining the aspect ratio
  27328. */
  27329. getScreenAspectRatio(): number;
  27330. /**
  27331. * Gets the current render width
  27332. * @param useScreen defines if screen size must be used (or the current render target if any)
  27333. * @returns a number defining the current render width
  27334. */
  27335. getRenderWidth(useScreen?: boolean): number;
  27336. /**
  27337. * Gets the current render height
  27338. * @param useScreen defines if screen size must be used (or the current render target if any)
  27339. * @returns a number defining the current render height
  27340. */
  27341. getRenderHeight(useScreen?: boolean): number;
  27342. /**
  27343. * Gets the HTML canvas attached with the current webGL context
  27344. * @returns a HTML canvas
  27345. */
  27346. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27347. /**
  27348. * Gets the client rect of the HTML canvas attached with the current webGL context
  27349. * @returns a client rectanglee
  27350. */
  27351. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27352. /**
  27353. * Defines the hardware scaling level.
  27354. * By default the hardware scaling level is computed from the window device ratio.
  27355. * 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.
  27356. * @param level defines the level to use
  27357. */
  27358. setHardwareScalingLevel(level: number): void;
  27359. /**
  27360. * Gets the current hardware scaling level.
  27361. * By default the hardware scaling level is computed from the window device ratio.
  27362. * 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.
  27363. * @returns a number indicating the current hardware scaling level
  27364. */
  27365. getHardwareScalingLevel(): number;
  27366. /**
  27367. * Gets the list of loaded textures
  27368. * @returns an array containing all loaded textures
  27369. */
  27370. getLoadedTexturesCache(): InternalTexture[];
  27371. /**
  27372. * Gets the object containing all engine capabilities
  27373. * @returns the EngineCapabilities object
  27374. */
  27375. getCaps(): EngineCapabilities;
  27376. /**
  27377. * Gets the current depth function
  27378. * @returns a number defining the depth function
  27379. */
  27380. getDepthFunction(): Nullable<number>;
  27381. /**
  27382. * Sets the current depth function
  27383. * @param depthFunc defines the function to use
  27384. */
  27385. setDepthFunction(depthFunc: number): void;
  27386. /**
  27387. * Sets the current depth function to GREATER
  27388. */
  27389. setDepthFunctionToGreater(): void;
  27390. /**
  27391. * Sets the current depth function to GEQUAL
  27392. */
  27393. setDepthFunctionToGreaterOrEqual(): void;
  27394. /**
  27395. * Sets the current depth function to LESS
  27396. */
  27397. setDepthFunctionToLess(): void;
  27398. private _cachedStencilBuffer;
  27399. private _cachedStencilFunction;
  27400. private _cachedStencilMask;
  27401. private _cachedStencilOperationPass;
  27402. private _cachedStencilOperationFail;
  27403. private _cachedStencilOperationDepthFail;
  27404. private _cachedStencilReference;
  27405. /**
  27406. * Caches the the state of the stencil buffer
  27407. */
  27408. cacheStencilState(): void;
  27409. /**
  27410. * Restores the state of the stencil buffer
  27411. */
  27412. restoreStencilState(): void;
  27413. /**
  27414. * Sets the current depth function to LEQUAL
  27415. */
  27416. setDepthFunctionToLessOrEqual(): void;
  27417. /**
  27418. * Gets a boolean indicating if stencil buffer is enabled
  27419. * @returns the current stencil buffer state
  27420. */
  27421. getStencilBuffer(): boolean;
  27422. /**
  27423. * Enable or disable the stencil buffer
  27424. * @param enable defines if the stencil buffer must be enabled or disabled
  27425. */
  27426. setStencilBuffer(enable: boolean): void;
  27427. /**
  27428. * Gets the current stencil mask
  27429. * @returns a number defining the new stencil mask to use
  27430. */
  27431. getStencilMask(): number;
  27432. /**
  27433. * Sets the current stencil mask
  27434. * @param mask defines the new stencil mask to use
  27435. */
  27436. setStencilMask(mask: number): void;
  27437. /**
  27438. * Gets the current stencil function
  27439. * @returns a number defining the stencil function to use
  27440. */
  27441. getStencilFunction(): number;
  27442. /**
  27443. * Gets the current stencil reference value
  27444. * @returns a number defining the stencil reference value to use
  27445. */
  27446. getStencilFunctionReference(): number;
  27447. /**
  27448. * Gets the current stencil mask
  27449. * @returns a number defining the stencil mask to use
  27450. */
  27451. getStencilFunctionMask(): number;
  27452. /**
  27453. * Sets the current stencil function
  27454. * @param stencilFunc defines the new stencil function to use
  27455. */
  27456. setStencilFunction(stencilFunc: number): void;
  27457. /**
  27458. * Sets the current stencil reference
  27459. * @param reference defines the new stencil reference to use
  27460. */
  27461. setStencilFunctionReference(reference: number): void;
  27462. /**
  27463. * Sets the current stencil mask
  27464. * @param mask defines the new stencil mask to use
  27465. */
  27466. setStencilFunctionMask(mask: number): void;
  27467. /**
  27468. * Gets the current stencil operation when stencil fails
  27469. * @returns a number defining stencil operation to use when stencil fails
  27470. */
  27471. getStencilOperationFail(): number;
  27472. /**
  27473. * Gets the current stencil operation when depth fails
  27474. * @returns a number defining stencil operation to use when depth fails
  27475. */
  27476. getStencilOperationDepthFail(): number;
  27477. /**
  27478. * Gets the current stencil operation when stencil passes
  27479. * @returns a number defining stencil operation to use when stencil passes
  27480. */
  27481. getStencilOperationPass(): number;
  27482. /**
  27483. * Sets the stencil operation to use when stencil fails
  27484. * @param operation defines the stencil operation to use when stencil fails
  27485. */
  27486. setStencilOperationFail(operation: number): void;
  27487. /**
  27488. * Sets the stencil operation to use when depth fails
  27489. * @param operation defines the stencil operation to use when depth fails
  27490. */
  27491. setStencilOperationDepthFail(operation: number): void;
  27492. /**
  27493. * Sets the stencil operation to use when stencil passes
  27494. * @param operation defines the stencil operation to use when stencil passes
  27495. */
  27496. setStencilOperationPass(operation: number): void;
  27497. /**
  27498. * Sets a boolean indicating if the dithering state is enabled or disabled
  27499. * @param value defines the dithering state
  27500. */
  27501. setDitheringState(value: boolean): void;
  27502. /**
  27503. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27504. * @param value defines the rasterizer state
  27505. */
  27506. setRasterizerState(value: boolean): void;
  27507. /**
  27508. * stop executing a render loop function and remove it from the execution array
  27509. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27510. */
  27511. stopRenderLoop(renderFunction?: () => void): void;
  27512. /** @hidden */ private _renderLoop(): void;
  27513. /**
  27514. * Register and execute a render loop. The engine can have more than one render function
  27515. * @param renderFunction defines the function to continuously execute
  27516. */
  27517. runRenderLoop(renderFunction: () => void): void;
  27518. /**
  27519. * Toggle full screen mode
  27520. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27521. */
  27522. switchFullscreen(requestPointerLock: boolean): void;
  27523. /**
  27524. * Enters full screen mode
  27525. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27526. */
  27527. enterFullscreen(requestPointerLock: boolean): void;
  27528. /**
  27529. * Exits full screen mode
  27530. */
  27531. exitFullscreen(): void;
  27532. /**
  27533. * Clear the current render buffer or the current render target (if any is set up)
  27534. * @param color defines the color to use
  27535. * @param backBuffer defines if the back buffer must be cleared
  27536. * @param depth defines if the depth buffer must be cleared
  27537. * @param stencil defines if the stencil buffer must be cleared
  27538. */
  27539. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27540. /**
  27541. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27542. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27543. * @param y defines the y-coordinate of the corner of the clear rectangle
  27544. * @param width defines the width of the clear rectangle
  27545. * @param height defines the height of the clear rectangle
  27546. * @param clearColor defines the clear color
  27547. */
  27548. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27549. /**
  27550. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27551. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27552. * @param y defines the y-coordinate of the corner of the clear rectangle
  27553. * @param width defines the width of the clear rectangle
  27554. * @param height defines the height of the clear rectangle
  27555. */
  27556. enableScissor(x: number, y: number, width: number, height: number): void;
  27557. /**
  27558. * Disable previously set scissor test rectangle
  27559. */
  27560. disableScissor(): void;
  27561. private _viewportCached;
  27562. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  27563. /**
  27564. * Set the WebGL's viewport
  27565. * @param viewport defines the viewport element to be used
  27566. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27567. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27568. */
  27569. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27570. /**
  27571. * Directly set the WebGL Viewport
  27572. * @param x defines the x coordinate of the viewport (in screen space)
  27573. * @param y defines the y coordinate of the viewport (in screen space)
  27574. * @param width defines the width of the viewport (in screen space)
  27575. * @param height defines the height of the viewport (in screen space)
  27576. * @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
  27577. */
  27578. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27579. /**
  27580. * Begin a new frame
  27581. */
  27582. beginFrame(): void;
  27583. /**
  27584. * Enf the current frame
  27585. */
  27586. endFrame(): void;
  27587. /**
  27588. * Resize the view according to the canvas' size
  27589. */
  27590. resize(): void;
  27591. /**
  27592. * Force a specific size of the canvas
  27593. * @param width defines the new canvas' width
  27594. * @param height defines the new canvas' height
  27595. */
  27596. setSize(width: number, height: number): void;
  27597. /**
  27598. * Binds the frame buffer to the specified texture.
  27599. * @param texture The texture to render to or null for the default canvas
  27600. * @param faceIndex The face of the texture to render to in case of cube texture
  27601. * @param requiredWidth The width of the target to render to
  27602. * @param requiredHeight The height of the target to render to
  27603. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27604. * @param depthStencilTexture The depth stencil texture to use to render
  27605. * @param lodLevel defines le lod level to bind to the frame buffer
  27606. */
  27607. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27608. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27609. /**
  27610. * Unbind the current render target texture from the webGL context
  27611. * @param texture defines the render target texture to unbind
  27612. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27613. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27614. */
  27615. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27616. /**
  27617. * Force the mipmap generation for the given render target texture
  27618. * @param texture defines the render target texture to use
  27619. */
  27620. generateMipMapsForCubemap(texture: InternalTexture): void;
  27621. /**
  27622. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27623. */
  27624. flushFramebuffer(): void;
  27625. /**
  27626. * Unbind the current render target and bind the default framebuffer
  27627. */
  27628. restoreDefaultFramebuffer(): void;
  27629. /**
  27630. * Create an uniform buffer
  27631. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27632. * @param elements defines the content of the uniform buffer
  27633. * @returns the webGL uniform buffer
  27634. */
  27635. createUniformBuffer(elements: FloatArray): DataBuffer;
  27636. /**
  27637. * Create a dynamic uniform buffer
  27638. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27639. * @param elements defines the content of the uniform buffer
  27640. * @returns the webGL uniform buffer
  27641. */
  27642. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27643. /**
  27644. * Update an existing uniform buffer
  27645. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27646. * @param uniformBuffer defines the target uniform buffer
  27647. * @param elements defines the content to update
  27648. * @param offset defines the offset in the uniform buffer where update should start
  27649. * @param count defines the size of the data to update
  27650. */
  27651. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27652. private _resetVertexBufferBinding;
  27653. /**
  27654. * Creates a vertex buffer
  27655. * @param data the data for the vertex buffer
  27656. * @returns the new WebGL static buffer
  27657. */
  27658. createVertexBuffer(data: DataArray): DataBuffer;
  27659. /**
  27660. * Creates a dynamic vertex buffer
  27661. * @param data the data for the dynamic vertex buffer
  27662. * @returns the new WebGL dynamic buffer
  27663. */
  27664. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27665. /**
  27666. * Update a dynamic index buffer
  27667. * @param indexBuffer defines the target index buffer
  27668. * @param indices defines the data to update
  27669. * @param offset defines the offset in the target index buffer where update should start
  27670. */
  27671. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27672. /**
  27673. * Updates a dynamic vertex buffer.
  27674. * @param vertexBuffer the vertex buffer to update
  27675. * @param data the data used to update the vertex buffer
  27676. * @param byteOffset the byte offset of the data
  27677. * @param byteLength the byte length of the data
  27678. */
  27679. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27680. private _resetIndexBufferBinding;
  27681. /**
  27682. * Creates a new index buffer
  27683. * @param indices defines the content of the index buffer
  27684. * @param updatable defines if the index buffer must be updatable
  27685. * @returns a new webGL buffer
  27686. */
  27687. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27688. /**
  27689. * Bind a webGL buffer to the webGL context
  27690. * @param buffer defines the buffer to bind
  27691. */
  27692. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27693. /**
  27694. * Bind an uniform buffer to the current webGL context
  27695. * @param buffer defines the buffer to bind
  27696. */
  27697. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27698. /**
  27699. * Bind a buffer to the current webGL context at a given location
  27700. * @param buffer defines the buffer to bind
  27701. * @param location defines the index where to bind the buffer
  27702. */
  27703. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27704. /**
  27705. * Bind a specific block at a given index in a specific shader program
  27706. * @param pipelineContext defines the pipeline context to use
  27707. * @param blockName defines the block name
  27708. * @param index defines the index where to bind the block
  27709. */
  27710. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27711. private bindIndexBuffer;
  27712. private bindBuffer;
  27713. /**
  27714. * update the bound buffer with the given data
  27715. * @param data defines the data to update
  27716. */
  27717. updateArrayBuffer(data: Float32Array): void;
  27718. private _vertexAttribPointer;
  27719. private _bindIndexBufferWithCache;
  27720. private _bindVertexBuffersAttributes;
  27721. /**
  27722. * Records a vertex array object
  27723. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27724. * @param vertexBuffers defines the list of vertex buffers to store
  27725. * @param indexBuffer defines the index buffer to store
  27726. * @param effect defines the effect to store
  27727. * @returns the new vertex array object
  27728. */
  27729. recordVertexArrayObject(vertexBuffers: {
  27730. [key: string]: VertexBuffer;
  27731. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27732. /**
  27733. * Bind a specific vertex array object
  27734. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27735. * @param vertexArrayObject defines the vertex array object to bind
  27736. * @param indexBuffer defines the index buffer to bind
  27737. */
  27738. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27739. /**
  27740. * Bind webGl buffers directly to the webGL context
  27741. * @param vertexBuffer defines the vertex buffer to bind
  27742. * @param indexBuffer defines the index buffer to bind
  27743. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27744. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27745. * @param effect defines the effect associated with the vertex buffer
  27746. */
  27747. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27748. private _unbindVertexArrayObject;
  27749. /**
  27750. * Bind a list of vertex buffers to the webGL context
  27751. * @param vertexBuffers defines the list of vertex buffers to bind
  27752. * @param indexBuffer defines the index buffer to bind
  27753. * @param effect defines the effect associated with the vertex buffers
  27754. */
  27755. bindBuffers(vertexBuffers: {
  27756. [key: string]: Nullable<VertexBuffer>;
  27757. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27758. /**
  27759. * Unbind all instance attributes
  27760. */
  27761. unbindInstanceAttributes(): void;
  27762. /**
  27763. * Release and free the memory of a vertex array object
  27764. * @param vao defines the vertex array object to delete
  27765. */
  27766. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27767. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  27768. /**
  27769. * Creates a webGL buffer to use with instanciation
  27770. * @param capacity defines the size of the buffer
  27771. * @returns the webGL buffer
  27772. */
  27773. createInstancesBuffer(capacity: number): DataBuffer;
  27774. /**
  27775. * Delete a webGL buffer used with instanciation
  27776. * @param buffer defines the webGL buffer to delete
  27777. */
  27778. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27779. /**
  27780. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27781. * @param instancesBuffer defines the webGL buffer to update and bind
  27782. * @param data defines the data to store in the buffer
  27783. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27784. */
  27785. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27786. /**
  27787. * Apply all cached states (depth, culling, stencil and alpha)
  27788. */
  27789. applyStates(): void;
  27790. /**
  27791. * Send a draw order
  27792. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27793. * @param indexStart defines the starting index
  27794. * @param indexCount defines the number of index to draw
  27795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27796. */
  27797. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27798. /**
  27799. * Draw a list of points
  27800. * @param verticesStart defines the index of first vertex to draw
  27801. * @param verticesCount defines the count of vertices to draw
  27802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27803. */
  27804. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27805. /**
  27806. * Draw a list of unindexed primitives
  27807. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27808. * @param verticesStart defines the index of first vertex to draw
  27809. * @param verticesCount defines the count of vertices to draw
  27810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27811. */
  27812. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27813. /**
  27814. * Draw a list of indexed primitives
  27815. * @param fillMode defines the primitive to use
  27816. * @param indexStart defines the starting index
  27817. * @param indexCount defines the number of index to draw
  27818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27819. */
  27820. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27821. /**
  27822. * Draw a list of unindexed primitives
  27823. * @param fillMode defines the primitive to use
  27824. * @param verticesStart defines the index of first vertex to draw
  27825. * @param verticesCount defines the count of vertices to draw
  27826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27827. */
  27828. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27829. private _drawMode;
  27830. /** @hidden */ private _releaseEffect(effect: Effect): void;
  27831. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  27832. /**
  27833. * Create a new effect (used to store vertex/fragment shaders)
  27834. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27835. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27836. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27837. * @param samplers defines an array of string used to represent textures
  27838. * @param defines defines the string containing the defines to use to compile the shaders
  27839. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27840. * @param onCompiled defines a function to call when the effect creation is successful
  27841. * @param onError defines a function to call when the effect creation has failed
  27842. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27843. * @returns the new Effect
  27844. */
  27845. 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;
  27846. private _compileShader;
  27847. private _compileRawShader;
  27848. /**
  27849. * Directly creates a webGL program
  27850. * @param pipelineContext defines the pipeline context to attach to
  27851. * @param vertexCode defines the vertex shader code to use
  27852. * @param fragmentCode defines the fragment shader code to use
  27853. * @param context defines the webGL context to use (if not set, the current one will be used)
  27854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27855. * @returns the new webGL program
  27856. */
  27857. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27858. /**
  27859. * Creates a webGL program
  27860. * @param pipelineContext defines the pipeline context to attach to
  27861. * @param vertexCode defines the vertex shader code to use
  27862. * @param fragmentCode defines the fragment shader code to use
  27863. * @param defines defines the string containing the defines to use to compile the shaders
  27864. * @param context defines the webGL context to use (if not set, the current one will be used)
  27865. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27866. * @returns the new webGL program
  27867. */
  27868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27869. /**
  27870. * Creates a new pipeline context
  27871. * @returns the new pipeline
  27872. */
  27873. createPipelineContext(): WebGLPipelineContext;
  27874. private _createShaderProgram;
  27875. private _finalizePipelineContext;
  27876. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27877. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27878. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27879. /**
  27880. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27881. * @param pipelineContext defines the pipeline context to use
  27882. * @param uniformsNames defines the list of uniform names
  27883. * @returns an array of webGL uniform locations
  27884. */
  27885. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27886. /**
  27887. * Gets the lsit of active attributes for a given webGL program
  27888. * @param pipelineContext defines the pipeline context to use
  27889. * @param attributesNames defines the list of attribute names to get
  27890. * @returns an array of indices indicating the offset of each attribute
  27891. */
  27892. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27893. /**
  27894. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27895. * @param effect defines the effect to activate
  27896. */
  27897. enableEffect(effect: Nullable<Effect>): void;
  27898. /**
  27899. * Set the value of an uniform to an array of int32
  27900. * @param uniform defines the webGL uniform location where to store the value
  27901. * @param array defines the array of int32 to store
  27902. */
  27903. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27904. /**
  27905. * Set the value of an uniform to an array of int32 (stored as vec2)
  27906. * @param uniform defines the webGL uniform location where to store the value
  27907. * @param array defines the array of int32 to store
  27908. */
  27909. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27910. /**
  27911. * Set the value of an uniform to an array of int32 (stored as vec3)
  27912. * @param uniform defines the webGL uniform location where to store the value
  27913. * @param array defines the array of int32 to store
  27914. */
  27915. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27916. /**
  27917. * Set the value of an uniform to an array of int32 (stored as vec4)
  27918. * @param uniform defines the webGL uniform location where to store the value
  27919. * @param array defines the array of int32 to store
  27920. */
  27921. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27922. /**
  27923. * Set the value of an uniform to an array of float32
  27924. * @param uniform defines the webGL uniform location where to store the value
  27925. * @param array defines the array of float32 to store
  27926. */
  27927. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27928. /**
  27929. * Set the value of an uniform to an array of float32 (stored as vec2)
  27930. * @param uniform defines the webGL uniform location where to store the value
  27931. * @param array defines the array of float32 to store
  27932. */
  27933. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27934. /**
  27935. * Set the value of an uniform to an array of float32 (stored as vec3)
  27936. * @param uniform defines the webGL uniform location where to store the value
  27937. * @param array defines the array of float32 to store
  27938. */
  27939. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27940. /**
  27941. * Set the value of an uniform to an array of float32 (stored as vec4)
  27942. * @param uniform defines the webGL uniform location where to store the value
  27943. * @param array defines the array of float32 to store
  27944. */
  27945. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27946. /**
  27947. * Set the value of an uniform to an array of number
  27948. * @param uniform defines the webGL uniform location where to store the value
  27949. * @param array defines the array of number to store
  27950. */
  27951. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27952. /**
  27953. * Set the value of an uniform to an array of number (stored as vec2)
  27954. * @param uniform defines the webGL uniform location where to store the value
  27955. * @param array defines the array of number to store
  27956. */
  27957. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27958. /**
  27959. * Set the value of an uniform to an array of number (stored as vec3)
  27960. * @param uniform defines the webGL uniform location where to store the value
  27961. * @param array defines the array of number to store
  27962. */
  27963. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27964. /**
  27965. * Set the value of an uniform to an array of number (stored as vec4)
  27966. * @param uniform defines the webGL uniform location where to store the value
  27967. * @param array defines the array of number to store
  27968. */
  27969. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27970. /**
  27971. * Set the value of an uniform to an array of float32 (stored as matrices)
  27972. * @param uniform defines the webGL uniform location where to store the value
  27973. * @param matrices defines the array of float32 to store
  27974. */
  27975. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27976. /**
  27977. * Set the value of an uniform to a matrix
  27978. * @param uniform defines the webGL uniform location where to store the value
  27979. * @param matrix defines the matrix to store
  27980. */
  27981. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27982. /**
  27983. * Set the value of an uniform to a matrix (3x3)
  27984. * @param uniform defines the webGL uniform location where to store the value
  27985. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27986. */
  27987. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27988. /**
  27989. * Set the value of an uniform to a matrix (2x2)
  27990. * @param uniform defines the webGL uniform location where to store the value
  27991. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27992. */
  27993. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27994. /**
  27995. * Set the value of an uniform to a number (int)
  27996. * @param uniform defines the webGL uniform location where to store the value
  27997. * @param value defines the int number to store
  27998. */
  27999. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28000. /**
  28001. * Set the value of an uniform to a number (float)
  28002. * @param uniform defines the webGL uniform location where to store the value
  28003. * @param value defines the float number to store
  28004. */
  28005. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28006. /**
  28007. * Set the value of an uniform to a vec2
  28008. * @param uniform defines the webGL uniform location where to store the value
  28009. * @param x defines the 1st component of the value
  28010. * @param y defines the 2nd component of the value
  28011. */
  28012. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28013. /**
  28014. * Set the value of an uniform to a vec3
  28015. * @param uniform defines the webGL uniform location where to store the value
  28016. * @param x defines the 1st component of the value
  28017. * @param y defines the 2nd component of the value
  28018. * @param z defines the 3rd component of the value
  28019. */
  28020. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28021. /**
  28022. * Set the value of an uniform to a boolean
  28023. * @param uniform defines the webGL uniform location where to store the value
  28024. * @param bool defines the boolean to store
  28025. */
  28026. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28027. /**
  28028. * Set the value of an uniform to a vec4
  28029. * @param uniform defines the webGL uniform location where to store the value
  28030. * @param x defines the 1st component of the value
  28031. * @param y defines the 2nd component of the value
  28032. * @param z defines the 3rd component of the value
  28033. * @param w defines the 4th component of the value
  28034. */
  28035. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28036. /**
  28037. * Set the value of an uniform to a Color3
  28038. * @param uniform defines the webGL uniform location where to store the value
  28039. * @param color3 defines the color to store
  28040. */
  28041. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28042. /**
  28043. * Set the value of an uniform to a Color3 and an alpha value
  28044. * @param uniform defines the webGL uniform location where to store the value
  28045. * @param color3 defines the color to store
  28046. * @param alpha defines the alpha component to store
  28047. */
  28048. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28049. /**
  28050. * Sets a Color4 on a uniform variable
  28051. * @param uniform defines the uniform location
  28052. * @param color4 defines the value to be set
  28053. */
  28054. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28055. /**
  28056. * Set various states to the webGL context
  28057. * @param culling defines backface culling state
  28058. * @param zOffset defines the value to apply to zOffset (0 by default)
  28059. * @param force defines if states must be applied even if cache is up to date
  28060. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28061. */
  28062. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28063. /**
  28064. * Set the z offset to apply to current rendering
  28065. * @param value defines the offset to apply
  28066. */
  28067. setZOffset(value: number): void;
  28068. /**
  28069. * Gets the current value of the zOffset
  28070. * @returns the current zOffset state
  28071. */
  28072. getZOffset(): number;
  28073. /**
  28074. * Enable or disable depth buffering
  28075. * @param enable defines the state to set
  28076. */
  28077. setDepthBuffer(enable: boolean): void;
  28078. /**
  28079. * Gets a boolean indicating if depth writing is enabled
  28080. * @returns the current depth writing state
  28081. */
  28082. getDepthWrite(): boolean;
  28083. /**
  28084. * Enable or disable depth writing
  28085. * @param enable defines the state to set
  28086. */
  28087. setDepthWrite(enable: boolean): void;
  28088. /**
  28089. * Enable or disable color writing
  28090. * @param enable defines the state to set
  28091. */
  28092. setColorWrite(enable: boolean): void;
  28093. /**
  28094. * Gets a boolean indicating if color writing is enabled
  28095. * @returns the current color writing state
  28096. */
  28097. getColorWrite(): boolean;
  28098. /**
  28099. * Sets alpha constants used by some alpha blending modes
  28100. * @param r defines the red component
  28101. * @param g defines the green component
  28102. * @param b defines the blue component
  28103. * @param a defines the alpha component
  28104. */
  28105. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28106. /**
  28107. * Sets the current alpha mode
  28108. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28109. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28111. */
  28112. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28113. /**
  28114. * Gets the current alpha mode
  28115. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28116. * @returns the current alpha mode
  28117. */
  28118. getAlphaMode(): number;
  28119. /**
  28120. * Clears the list of texture accessible through engine.
  28121. * This can help preventing texture load conflict due to name collision.
  28122. */
  28123. clearInternalTexturesCache(): void;
  28124. /**
  28125. * Force the entire cache to be cleared
  28126. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28127. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28128. */
  28129. wipeCaches(bruteForce?: boolean): void;
  28130. /**
  28131. * Set the compressed texture format to use, based on the formats you have, and the formats
  28132. * supported by the hardware / browser.
  28133. *
  28134. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28135. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28136. * to API arguments needed to compressed textures. This puts the burden on the container
  28137. * generator to house the arcane code for determining these for current & future formats.
  28138. *
  28139. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28140. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28141. *
  28142. * Note: The result of this call is not taken into account when a texture is base64.
  28143. *
  28144. * @param formatsAvailable defines the list of those format families you have created
  28145. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28146. *
  28147. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28148. * @returns The extension selected.
  28149. */
  28150. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28151. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28152. min: number;
  28153. mag: number;
  28154. };
  28155. /** @hidden */ private _createTexture(): WebGLTexture;
  28156. /**
  28157. * Usually called from Texture.ts.
  28158. * Passed information to create a WebGLTexture
  28159. * @param urlArg defines a value which contains one of the following:
  28160. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28161. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28162. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28163. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28164. * @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)
  28165. * @param scene needed for loading to the correct scene
  28166. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28167. * @param onLoad optional callback to be called upon successful completion
  28168. * @param onError optional callback to be called upon failure
  28169. * @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
  28170. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28171. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28172. * @param forcedExtension defines the extension to use to pick the right loader
  28173. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28174. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28175. */
  28176. 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;
  28177. private _rescaleTexture;
  28178. private _unpackFlipYCached;
  28179. /**
  28180. * In case you are sharing the context with other applications, it might
  28181. * be interested to not cache the unpack flip y state to ensure a consistent
  28182. * value would be set.
  28183. */
  28184. enableUnpackFlipYCached: boolean;
  28185. /** @hidden */ private _unpackFlipY(value: boolean): void;
  28186. /** @hidden */ private _getUnpackAlignement(): number;
  28187. /**
  28188. * Creates a dynamic texture
  28189. * @param width defines the width of the texture
  28190. * @param height defines the height of the texture
  28191. * @param generateMipMaps defines if the engine should generate the mip levels
  28192. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28193. * @returns the dynamic texture inside an InternalTexture
  28194. */
  28195. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28196. /**
  28197. * Update the sampling mode of a given texture
  28198. * @param samplingMode defines the required sampling mode
  28199. * @param texture defines the texture to update
  28200. */
  28201. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28202. /**
  28203. * Update the content of a dynamic texture
  28204. * @param texture defines the texture to update
  28205. * @param canvas defines the canvas containing the source
  28206. * @param invertY defines if data must be stored with Y axis inverted
  28207. * @param premulAlpha defines if alpha is stored as premultiplied
  28208. * @param format defines the format of the data
  28209. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28210. */
  28211. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28212. /**
  28213. * Update a video texture
  28214. * @param texture defines the texture to update
  28215. * @param video defines the video element to use
  28216. * @param invertY defines if data must be stored with Y axis inverted
  28217. */
  28218. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28219. /**
  28220. * Updates a depth texture Comparison Mode and Function.
  28221. * If the comparison Function is equal to 0, the mode will be set to none.
  28222. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28223. * @param texture The texture to set the comparison function for
  28224. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28225. */
  28226. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28227. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28228. width: number;
  28229. height: number;
  28230. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28231. /**
  28232. * Creates a depth stencil texture.
  28233. * This is only available in WebGL 2 or with the depth texture extension available.
  28234. * @param size The size of face edge in the texture.
  28235. * @param options The options defining the texture.
  28236. * @returns The texture
  28237. */
  28238. createDepthStencilTexture(size: number | {
  28239. width: number;
  28240. height: number;
  28241. }, options: DepthTextureCreationOptions): InternalTexture;
  28242. /**
  28243. * Creates a depth stencil texture.
  28244. * This is only available in WebGL 2 or with the depth texture extension available.
  28245. * @param size The size of face edge in the texture.
  28246. * @param options The options defining the texture.
  28247. * @returns The texture
  28248. */
  28249. private _createDepthStencilTexture;
  28250. /**
  28251. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28252. * @param renderTarget The render target to set the frame buffer for
  28253. */
  28254. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28255. /**
  28256. * Creates a new render target texture
  28257. * @param size defines the size of the texture
  28258. * @param options defines the options used to create the texture
  28259. * @returns a new render target texture stored in an InternalTexture
  28260. */
  28261. createRenderTargetTexture(size: number | {
  28262. width: number;
  28263. height: number;
  28264. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28265. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28266. /**
  28267. * Updates the sample count of a render target texture
  28268. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28269. * @param texture defines the texture to update
  28270. * @param samples defines the sample count to set
  28271. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28272. */
  28273. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28274. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28275. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28276. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28277. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28278. /**
  28279. * @hidden
  28280. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  28281. private _prepareWebGLTextureContinuation;
  28282. private _prepareWebGLTexture;
  28283. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28284. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  28285. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  28286. private setProgram;
  28287. private _boundUniforms;
  28288. /**
  28289. * Binds an effect to the webGL context
  28290. * @param effect defines the effect to bind
  28291. */
  28292. bindSamplers(effect: Effect): void;
  28293. private _activateCurrentTexture;
  28294. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28295. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28296. /**
  28297. * Sets a texture to the webGL context from a postprocess
  28298. * @param channel defines the channel to use
  28299. * @param postProcess defines the source postprocess
  28300. */
  28301. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28302. /**
  28303. * Binds the output of the passed in post process to the texture channel specified
  28304. * @param channel The channel the texture should be bound to
  28305. * @param postProcess The post process which's output should be bound
  28306. */
  28307. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28308. /**
  28309. * Unbind all textures from the webGL context
  28310. */
  28311. unbindAllTextures(): void;
  28312. /**
  28313. * Sets a texture to the according uniform.
  28314. * @param channel The texture channel
  28315. * @param uniform The uniform to set
  28316. * @param texture The texture to apply
  28317. */
  28318. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28319. /**
  28320. * Sets a depth stencil texture from a render target to the according uniform.
  28321. * @param channel The texture channel
  28322. * @param uniform The uniform to set
  28323. * @param texture The render target texture containing the depth stencil texture to apply
  28324. */
  28325. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28326. private _bindSamplerUniformToChannel;
  28327. private _getTextureWrapMode;
  28328. private _setTexture;
  28329. /**
  28330. * Sets an array of texture to the webGL context
  28331. * @param channel defines the channel where the texture array must be set
  28332. * @param uniform defines the associated uniform location
  28333. * @param textures defines the array of textures to bind
  28334. */
  28335. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28336. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28337. private _setTextureParameterFloat;
  28338. private _setTextureParameterInteger;
  28339. /**
  28340. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28341. * @param x defines the x coordinate of the rectangle where pixels must be read
  28342. * @param y defines the y coordinate of the rectangle where pixels must be read
  28343. * @param width defines the width of the rectangle where pixels must be read
  28344. * @param height defines the height of the rectangle where pixels must be read
  28345. * @returns a Uint8Array containing RGBA colors
  28346. */
  28347. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28348. /**
  28349. * Add an externaly attached data from its key.
  28350. * This method call will fail and return false, if such key already exists.
  28351. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28352. * @param key the unique key that identifies the data
  28353. * @param data the data object to associate to the key for this Engine instance
  28354. * @return true if no such key were already present and the data was added successfully, false otherwise
  28355. */
  28356. addExternalData<T>(key: string, data: T): boolean;
  28357. /**
  28358. * Get an externaly attached data from its key
  28359. * @param key the unique key that identifies the data
  28360. * @return the associated data, if present (can be null), or undefined if not present
  28361. */
  28362. getExternalData<T>(key: string): T;
  28363. /**
  28364. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28365. * @param key the unique key that identifies the data
  28366. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28367. * @return the associated data, can be null if the factory returned null.
  28368. */
  28369. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28370. /**
  28371. * Remove an externaly attached data from the Engine instance
  28372. * @param key the unique key that identifies the data
  28373. * @return true if the data was successfully removed, false if it doesn't exist
  28374. */
  28375. removeExternalData(key: string): boolean;
  28376. /**
  28377. * Unbind all vertex attributes from the webGL context
  28378. */
  28379. unbindAllAttributes(): void;
  28380. /**
  28381. * 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
  28382. */
  28383. releaseEffects(): void;
  28384. /**
  28385. * Dispose and release all associated resources
  28386. */
  28387. dispose(): void;
  28388. /**
  28389. * Display the loading screen
  28390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28391. */
  28392. displayLoadingUI(): void;
  28393. /**
  28394. * Hide the loading screen
  28395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28396. */
  28397. hideLoadingUI(): void;
  28398. /**
  28399. * Gets the current loading screen object
  28400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28401. */
  28402. /**
  28403. * Sets the current loading screen object
  28404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28405. */
  28406. loadingScreen: ILoadingScreen;
  28407. /**
  28408. * Sets the current loading screen text
  28409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28410. */
  28411. loadingUIText: string;
  28412. /**
  28413. * Sets the current loading screen background color
  28414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28415. */
  28416. loadingUIBackgroundColor: string;
  28417. /**
  28418. * Attach a new callback raised when context lost event is fired
  28419. * @param callback defines the callback to call
  28420. */
  28421. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28422. /**
  28423. * Attach a new callback raised when context restored event is fired
  28424. * @param callback defines the callback to call
  28425. */
  28426. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28427. /**
  28428. * Gets the source code of the vertex shader associated with a specific webGL program
  28429. * @param program defines the program to use
  28430. * @returns a string containing the source code of the vertex shader associated with the program
  28431. */
  28432. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28433. /**
  28434. * Gets the source code of the fragment shader associated with a specific webGL program
  28435. * @param program defines the program to use
  28436. * @returns a string containing the source code of the fragment shader associated with the program
  28437. */
  28438. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28439. /**
  28440. * Get the current error code of the webGL context
  28441. * @returns the error code
  28442. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28443. */
  28444. getError(): number;
  28445. /**
  28446. * Gets the current framerate
  28447. * @returns a number representing the framerate
  28448. */
  28449. getFps(): number;
  28450. /**
  28451. * Gets the time spent between current and previous frame
  28452. * @returns a number representing the delta time in ms
  28453. */
  28454. getDeltaTime(): number;
  28455. private _measureFps;
  28456. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28457. private _canRenderToFloatFramebuffer;
  28458. private _canRenderToHalfFloatFramebuffer;
  28459. private _canRenderToFramebuffer;
  28460. /** @hidden */ private _getWebGLTextureType(type: number): number;
  28461. /** @hidden */ private _getInternalFormat(format: number): number;
  28462. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28463. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  28464. /** @hidden */ private _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;
  28465. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28466. /**
  28467. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28468. * @returns true if the engine can be created
  28469. * @ignorenaming
  28470. */
  28471. static isSupported(): boolean;
  28472. }
  28473. }
  28474. declare module BABYLON {
  28475. /**
  28476. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28477. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28478. */
  28479. export class EffectFallbacks {
  28480. private _defines;
  28481. private _currentRank;
  28482. private _maxRank;
  28483. private _mesh;
  28484. /**
  28485. * Removes the fallback from the bound mesh.
  28486. */
  28487. unBindMesh(): void;
  28488. /**
  28489. * Adds a fallback on the specified property.
  28490. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28491. * @param define The name of the define in the shader
  28492. */
  28493. addFallback(rank: number, define: string): void;
  28494. /**
  28495. * Sets the mesh to use CPU skinning when needing to fallback.
  28496. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28497. * @param mesh The mesh to use the fallbacks.
  28498. */
  28499. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28500. /**
  28501. * Checks to see if more fallbacks are still availible.
  28502. */
  28503. readonly isMoreFallbacks: boolean;
  28504. /**
  28505. * Removes the defines that shoould be removed when falling back.
  28506. * @param currentDefines defines the current define statements for the shader.
  28507. * @param effect defines the current effect we try to compile
  28508. * @returns The resulting defines with defines of the current rank removed.
  28509. */
  28510. reduce(currentDefines: string, effect: Effect): string;
  28511. }
  28512. /**
  28513. * Options to be used when creating an effect.
  28514. */
  28515. export class EffectCreationOptions {
  28516. /**
  28517. * Atrributes that will be used in the shader.
  28518. */
  28519. attributes: string[];
  28520. /**
  28521. * Uniform varible names that will be set in the shader.
  28522. */
  28523. uniformsNames: string[];
  28524. /**
  28525. * Uniform buffer varible names that will be set in the shader.
  28526. */
  28527. uniformBuffersNames: string[];
  28528. /**
  28529. * Sampler texture variable names that will be set in the shader.
  28530. */
  28531. samplers: string[];
  28532. /**
  28533. * Define statements that will be set in the shader.
  28534. */
  28535. defines: any;
  28536. /**
  28537. * Possible fallbacks for this effect to improve performance when needed.
  28538. */
  28539. fallbacks: Nullable<EffectFallbacks>;
  28540. /**
  28541. * Callback that will be called when the shader is compiled.
  28542. */
  28543. onCompiled: Nullable<(effect: Effect) => void>;
  28544. /**
  28545. * Callback that will be called if an error occurs during shader compilation.
  28546. */
  28547. onError: Nullable<(effect: Effect, errors: string) => void>;
  28548. /**
  28549. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28550. */
  28551. indexParameters: any;
  28552. /**
  28553. * Max number of lights that can be used in the shader.
  28554. */
  28555. maxSimultaneousLights: number;
  28556. /**
  28557. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28558. */
  28559. transformFeedbackVaryings: Nullable<string[]>;
  28560. }
  28561. /**
  28562. * Effect containing vertex and fragment shader that can be executed on an object.
  28563. */
  28564. export class Effect implements IDisposable {
  28565. /**
  28566. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28567. */
  28568. static ShadersRepository: string;
  28569. /**
  28570. * Name of the effect.
  28571. */
  28572. name: any;
  28573. /**
  28574. * String container all the define statements that should be set on the shader.
  28575. */
  28576. defines: string;
  28577. /**
  28578. * Callback that will be called when the shader is compiled.
  28579. */
  28580. onCompiled: Nullable<(effect: Effect) => void>;
  28581. /**
  28582. * Callback that will be called if an error occurs during shader compilation.
  28583. */
  28584. onError: Nullable<(effect: Effect, errors: string) => void>;
  28585. /**
  28586. * Callback that will be called when effect is bound.
  28587. */
  28588. onBind: Nullable<(effect: Effect) => void>;
  28589. /**
  28590. * Unique ID of the effect.
  28591. */
  28592. uniqueId: number;
  28593. /**
  28594. * Observable that will be called when the shader is compiled.
  28595. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28596. */
  28597. onCompileObservable: Observable<Effect>;
  28598. /**
  28599. * Observable that will be called if an error occurs during shader compilation.
  28600. */
  28601. onErrorObservable: Observable<Effect>;
  28602. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  28603. /**
  28604. * Observable that will be called when effect is bound.
  28605. */
  28606. readonly onBindObservable: Observable<Effect>;
  28607. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  28608. private static _uniqueIdSeed;
  28609. private _engine;
  28610. private _uniformBuffersNames;
  28611. private _uniformsNames;
  28612. private _samplerList;
  28613. private _samplers;
  28614. private _isReady;
  28615. private _compilationError;
  28616. private _attributesNames;
  28617. private _attributes;
  28618. private _uniforms;
  28619. /**
  28620. * Key for the effect.
  28621. * @hidden
  28622. */ private _key: string;
  28623. private _indexParameters;
  28624. private _fallbacks;
  28625. private _vertexSourceCode;
  28626. private _fragmentSourceCode;
  28627. private _vertexSourceCodeOverride;
  28628. private _fragmentSourceCodeOverride;
  28629. private _transformFeedbackVaryings;
  28630. /**
  28631. * Compiled shader to webGL program.
  28632. * @hidden
  28633. */ private _pipelineContext: Nullable<IPipelineContext>;
  28634. private _valueCache;
  28635. private static _baseCache;
  28636. /**
  28637. * Instantiates an effect.
  28638. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28639. * @param baseName Name of the effect.
  28640. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28641. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28642. * @param samplers List of sampler variables that will be passed to the shader.
  28643. * @param engine Engine to be used to render the effect
  28644. * @param defines Define statements to be added to the shader.
  28645. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28646. * @param onCompiled Callback that will be called when the shader is compiled.
  28647. * @param onError Callback that will be called if an error occurs during shader compilation.
  28648. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28649. */
  28650. 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);
  28651. /**
  28652. * Unique key for this effect
  28653. */
  28654. readonly key: string;
  28655. /**
  28656. * If the effect has been compiled and prepared.
  28657. * @returns if the effect is compiled and prepared.
  28658. */
  28659. isReady(): boolean;
  28660. /**
  28661. * The engine the effect was initialized with.
  28662. * @returns the engine.
  28663. */
  28664. getEngine(): Engine;
  28665. /**
  28666. * The pipeline context for this effect
  28667. * @returns the associated pipeline context
  28668. */
  28669. getPipelineContext(): Nullable<IPipelineContext>;
  28670. /**
  28671. * The set of names of attribute variables for the shader.
  28672. * @returns An array of attribute names.
  28673. */
  28674. getAttributesNames(): string[];
  28675. /**
  28676. * Returns the attribute at the given index.
  28677. * @param index The index of the attribute.
  28678. * @returns The location of the attribute.
  28679. */
  28680. getAttributeLocation(index: number): number;
  28681. /**
  28682. * Returns the attribute based on the name of the variable.
  28683. * @param name of the attribute to look up.
  28684. * @returns the attribute location.
  28685. */
  28686. getAttributeLocationByName(name: string): number;
  28687. /**
  28688. * The number of attributes.
  28689. * @returns the numnber of attributes.
  28690. */
  28691. getAttributesCount(): number;
  28692. /**
  28693. * Gets the index of a uniform variable.
  28694. * @param uniformName of the uniform to look up.
  28695. * @returns the index.
  28696. */
  28697. getUniformIndex(uniformName: string): number;
  28698. /**
  28699. * Returns the attribute based on the name of the variable.
  28700. * @param uniformName of the uniform to look up.
  28701. * @returns the location of the uniform.
  28702. */
  28703. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28704. /**
  28705. * Returns an array of sampler variable names
  28706. * @returns The array of sampler variable neames.
  28707. */
  28708. getSamplers(): string[];
  28709. /**
  28710. * The error from the last compilation.
  28711. * @returns the error string.
  28712. */
  28713. getCompilationError(): string;
  28714. /**
  28715. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28716. * @param func The callback to be used.
  28717. */
  28718. executeWhenCompiled(func: (effect: Effect) => void): void;
  28719. private _checkIsReady;
  28720. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28721. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28722. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28723. private _processShaderConversion;
  28724. private _processIncludes;
  28725. private _processPrecision;
  28726. /**
  28727. * Recompiles the webGL program
  28728. * @param vertexSourceCode The source code for the vertex shader.
  28729. * @param fragmentSourceCode The source code for the fragment shader.
  28730. * @param onCompiled Callback called when completed.
  28731. * @param onError Callback called on error.
  28732. * @hidden
  28733. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28734. /**
  28735. * Prepares the effect
  28736. * @hidden
  28737. */ private _prepareEffect(): void;
  28738. /**
  28739. * Checks if the effect is supported. (Must be called after compilation)
  28740. */
  28741. readonly isSupported: boolean;
  28742. /**
  28743. * Binds a texture to the engine to be used as output of the shader.
  28744. * @param channel Name of the output variable.
  28745. * @param texture Texture to bind.
  28746. * @hidden
  28747. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  28748. /**
  28749. * Sets a texture on the engine to be used in the shader.
  28750. * @param channel Name of the sampler variable.
  28751. * @param texture Texture to set.
  28752. */
  28753. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28754. /**
  28755. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28756. * @param channel Name of the sampler variable.
  28757. * @param texture Texture to set.
  28758. */
  28759. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28760. /**
  28761. * Sets an array of textures on the engine to be used in the shader.
  28762. * @param channel Name of the variable.
  28763. * @param textures Textures to set.
  28764. */
  28765. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28766. /**
  28767. * 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)
  28768. * @param channel Name of the sampler variable.
  28769. * @param postProcess Post process to get the input texture from.
  28770. */
  28771. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28772. /**
  28773. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28774. * 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)
  28775. * @param channel Name of the sampler variable.
  28776. * @param postProcess Post process to get the output texture from.
  28777. */
  28778. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28779. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28780. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28781. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28782. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28783. /**
  28784. * Binds a buffer to a uniform.
  28785. * @param buffer Buffer to bind.
  28786. * @param name Name of the uniform variable to bind to.
  28787. */
  28788. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28789. /**
  28790. * Binds block to a uniform.
  28791. * @param blockName Name of the block to bind.
  28792. * @param index Index to bind.
  28793. */
  28794. bindUniformBlock(blockName: string, index: number): void;
  28795. /**
  28796. * Sets an interger value on a uniform variable.
  28797. * @param uniformName Name of the variable.
  28798. * @param value Value to be set.
  28799. * @returns this effect.
  28800. */
  28801. setInt(uniformName: string, value: number): Effect;
  28802. /**
  28803. * Sets an int array on a uniform variable.
  28804. * @param uniformName Name of the variable.
  28805. * @param array array to be set.
  28806. * @returns this effect.
  28807. */
  28808. setIntArray(uniformName: string, array: Int32Array): Effect;
  28809. /**
  28810. * 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)
  28811. * @param uniformName Name of the variable.
  28812. * @param array array to be set.
  28813. * @returns this effect.
  28814. */
  28815. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28816. /**
  28817. * 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)
  28818. * @param uniformName Name of the variable.
  28819. * @param array array to be set.
  28820. * @returns this effect.
  28821. */
  28822. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28823. /**
  28824. * 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)
  28825. * @param uniformName Name of the variable.
  28826. * @param array array to be set.
  28827. * @returns this effect.
  28828. */
  28829. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28830. /**
  28831. * Sets an float array on a uniform variable.
  28832. * @param uniformName Name of the variable.
  28833. * @param array array to be set.
  28834. * @returns this effect.
  28835. */
  28836. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28837. /**
  28838. * 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)
  28839. * @param uniformName Name of the variable.
  28840. * @param array array to be set.
  28841. * @returns this effect.
  28842. */
  28843. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28844. /**
  28845. * 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)
  28846. * @param uniformName Name of the variable.
  28847. * @param array array to be set.
  28848. * @returns this effect.
  28849. */
  28850. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28851. /**
  28852. * 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)
  28853. * @param uniformName Name of the variable.
  28854. * @param array array to be set.
  28855. * @returns this effect.
  28856. */
  28857. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28858. /**
  28859. * Sets an array on a uniform variable.
  28860. * @param uniformName Name of the variable.
  28861. * @param array array to be set.
  28862. * @returns this effect.
  28863. */
  28864. setArray(uniformName: string, array: number[]): Effect;
  28865. /**
  28866. * 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)
  28867. * @param uniformName Name of the variable.
  28868. * @param array array to be set.
  28869. * @returns this effect.
  28870. */
  28871. setArray2(uniformName: string, array: number[]): Effect;
  28872. /**
  28873. * 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)
  28874. * @param uniformName Name of the variable.
  28875. * @param array array to be set.
  28876. * @returns this effect.
  28877. */
  28878. setArray3(uniformName: string, array: number[]): Effect;
  28879. /**
  28880. * 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)
  28881. * @param uniformName Name of the variable.
  28882. * @param array array to be set.
  28883. * @returns this effect.
  28884. */
  28885. setArray4(uniformName: string, array: number[]): Effect;
  28886. /**
  28887. * Sets matrices on a uniform variable.
  28888. * @param uniformName Name of the variable.
  28889. * @param matrices matrices to be set.
  28890. * @returns this effect.
  28891. */
  28892. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28893. /**
  28894. * Sets matrix on a uniform variable.
  28895. * @param uniformName Name of the variable.
  28896. * @param matrix matrix to be set.
  28897. * @returns this effect.
  28898. */
  28899. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28900. /**
  28901. * 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)
  28902. * @param uniformName Name of the variable.
  28903. * @param matrix matrix to be set.
  28904. * @returns this effect.
  28905. */
  28906. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28907. /**
  28908. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28909. * @param uniformName Name of the variable.
  28910. * @param matrix matrix to be set.
  28911. * @returns this effect.
  28912. */
  28913. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28914. /**
  28915. * Sets a float on a uniform variable.
  28916. * @param uniformName Name of the variable.
  28917. * @param value value to be set.
  28918. * @returns this effect.
  28919. */
  28920. setFloat(uniformName: string, value: number): Effect;
  28921. /**
  28922. * Sets a boolean on a uniform variable.
  28923. * @param uniformName Name of the variable.
  28924. * @param bool value to be set.
  28925. * @returns this effect.
  28926. */
  28927. setBool(uniformName: string, bool: boolean): Effect;
  28928. /**
  28929. * Sets a Vector2 on a uniform variable.
  28930. * @param uniformName Name of the variable.
  28931. * @param vector2 vector2 to be set.
  28932. * @returns this effect.
  28933. */
  28934. setVector2(uniformName: string, vector2: Vector2): Effect;
  28935. /**
  28936. * Sets a float2 on a uniform variable.
  28937. * @param uniformName Name of the variable.
  28938. * @param x First float in float2.
  28939. * @param y Second float in float2.
  28940. * @returns this effect.
  28941. */
  28942. setFloat2(uniformName: string, x: number, y: number): Effect;
  28943. /**
  28944. * Sets a Vector3 on a uniform variable.
  28945. * @param uniformName Name of the variable.
  28946. * @param vector3 Value to be set.
  28947. * @returns this effect.
  28948. */
  28949. setVector3(uniformName: string, vector3: Vector3): Effect;
  28950. /**
  28951. * Sets a float3 on a uniform variable.
  28952. * @param uniformName Name of the variable.
  28953. * @param x First float in float3.
  28954. * @param y Second float in float3.
  28955. * @param z Third float in float3.
  28956. * @returns this effect.
  28957. */
  28958. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28959. /**
  28960. * Sets a Vector4 on a uniform variable.
  28961. * @param uniformName Name of the variable.
  28962. * @param vector4 Value to be set.
  28963. * @returns this effect.
  28964. */
  28965. setVector4(uniformName: string, vector4: Vector4): Effect;
  28966. /**
  28967. * Sets a float4 on a uniform variable.
  28968. * @param uniformName Name of the variable.
  28969. * @param x First float in float4.
  28970. * @param y Second float in float4.
  28971. * @param z Third float in float4.
  28972. * @param w Fourth float in float4.
  28973. * @returns this effect.
  28974. */
  28975. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28976. /**
  28977. * Sets a Color3 on a uniform variable.
  28978. * @param uniformName Name of the variable.
  28979. * @param color3 Value to be set.
  28980. * @returns this effect.
  28981. */
  28982. setColor3(uniformName: string, color3: Color3): Effect;
  28983. /**
  28984. * Sets a Color4 on a uniform variable.
  28985. * @param uniformName Name of the variable.
  28986. * @param color3 Value to be set.
  28987. * @param alpha Alpha value to be set.
  28988. * @returns this effect.
  28989. */
  28990. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28991. /**
  28992. * Sets a Color4 on a uniform variable
  28993. * @param uniformName defines the name of the variable
  28994. * @param color4 defines the value to be set
  28995. * @returns this effect.
  28996. */
  28997. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28998. /** Release all associated resources */
  28999. dispose(): void;
  29000. /**
  29001. * This function will add a new shader to the shader store
  29002. * @param name the name of the shader
  29003. * @param pixelShader optional pixel shader content
  29004. * @param vertexShader optional vertex shader content
  29005. */
  29006. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29007. /**
  29008. * Store of each shader (The can be looked up using effect.key)
  29009. */
  29010. static ShadersStore: {
  29011. [key: string]: string;
  29012. };
  29013. /**
  29014. * Store of each included file for a shader (The can be looked up using effect.key)
  29015. */
  29016. static IncludesShadersStore: {
  29017. [key: string]: string;
  29018. };
  29019. /**
  29020. * Resets the cache of effects.
  29021. */
  29022. static ResetCache(): void;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. /**
  29027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29029. * 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;
  29030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29031. */
  29032. export class ColorCurves {
  29033. private _dirty;
  29034. private _tempColor;
  29035. private _globalCurve;
  29036. private _highlightsCurve;
  29037. private _midtonesCurve;
  29038. private _shadowsCurve;
  29039. private _positiveCurve;
  29040. private _negativeCurve;
  29041. private _globalHue;
  29042. private _globalDensity;
  29043. private _globalSaturation;
  29044. private _globalExposure;
  29045. /**
  29046. * Gets the global Hue value.
  29047. * 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).
  29048. */
  29049. /**
  29050. * Sets the global Hue value.
  29051. * 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).
  29052. */
  29053. globalHue: number;
  29054. /**
  29055. * Gets the global Density value.
  29056. * 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.
  29057. * Values less than zero provide a filter of opposite hue.
  29058. */
  29059. /**
  29060. * Sets the global Density value.
  29061. * 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.
  29062. * Values less than zero provide a filter of opposite hue.
  29063. */
  29064. globalDensity: number;
  29065. /**
  29066. * Gets the global Saturation value.
  29067. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29068. */
  29069. /**
  29070. * Sets the global Saturation value.
  29071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29072. */
  29073. globalSaturation: number;
  29074. /**
  29075. * Gets the global Exposure value.
  29076. * 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.
  29077. */
  29078. /**
  29079. * Sets the global Exposure value.
  29080. * 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.
  29081. */
  29082. globalExposure: number;
  29083. private _highlightsHue;
  29084. private _highlightsDensity;
  29085. private _highlightsSaturation;
  29086. private _highlightsExposure;
  29087. /**
  29088. * Gets the highlights Hue value.
  29089. * 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).
  29090. */
  29091. /**
  29092. * Sets the highlights Hue value.
  29093. * 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).
  29094. */
  29095. highlightsHue: number;
  29096. /**
  29097. * Gets the highlights Density value.
  29098. * 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.
  29099. * Values less than zero provide a filter of opposite hue.
  29100. */
  29101. /**
  29102. * Sets the highlights Density value.
  29103. * 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.
  29104. * Values less than zero provide a filter of opposite hue.
  29105. */
  29106. highlightsDensity: number;
  29107. /**
  29108. * Gets the highlights Saturation value.
  29109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29110. */
  29111. /**
  29112. * Sets the highlights Saturation value.
  29113. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29114. */
  29115. highlightsSaturation: number;
  29116. /**
  29117. * Gets the highlights Exposure value.
  29118. * 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.
  29119. */
  29120. /**
  29121. * Sets the highlights Exposure value.
  29122. * 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.
  29123. */
  29124. highlightsExposure: number;
  29125. private _midtonesHue;
  29126. private _midtonesDensity;
  29127. private _midtonesSaturation;
  29128. private _midtonesExposure;
  29129. /**
  29130. * Gets the midtones Hue value.
  29131. * 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).
  29132. */
  29133. /**
  29134. * Sets the midtones Hue value.
  29135. * 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).
  29136. */
  29137. midtonesHue: number;
  29138. /**
  29139. * Gets the midtones Density value.
  29140. * 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.
  29141. * Values less than zero provide a filter of opposite hue.
  29142. */
  29143. /**
  29144. * Sets the midtones Density value.
  29145. * 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.
  29146. * Values less than zero provide a filter of opposite hue.
  29147. */
  29148. midtonesDensity: number;
  29149. /**
  29150. * Gets the midtones Saturation value.
  29151. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29152. */
  29153. /**
  29154. * Sets the midtones Saturation value.
  29155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29156. */
  29157. midtonesSaturation: number;
  29158. /**
  29159. * Gets the midtones Exposure value.
  29160. * 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.
  29161. */
  29162. /**
  29163. * Sets the midtones Exposure value.
  29164. * 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.
  29165. */
  29166. midtonesExposure: number;
  29167. private _shadowsHue;
  29168. private _shadowsDensity;
  29169. private _shadowsSaturation;
  29170. private _shadowsExposure;
  29171. /**
  29172. * Gets the shadows Hue value.
  29173. * 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).
  29174. */
  29175. /**
  29176. * Sets the shadows Hue value.
  29177. * 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).
  29178. */
  29179. shadowsHue: number;
  29180. /**
  29181. * Gets the shadows Density value.
  29182. * 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.
  29183. * Values less than zero provide a filter of opposite hue.
  29184. */
  29185. /**
  29186. * Sets the shadows Density value.
  29187. * 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.
  29188. * Values less than zero provide a filter of opposite hue.
  29189. */
  29190. shadowsDensity: number;
  29191. /**
  29192. * Gets the shadows Saturation value.
  29193. * 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.
  29194. */
  29195. /**
  29196. * Sets the shadows Saturation value.
  29197. * 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.
  29198. */
  29199. shadowsSaturation: number;
  29200. /**
  29201. * Gets the shadows Exposure value.
  29202. * 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.
  29203. */
  29204. /**
  29205. * Sets the shadows Exposure value.
  29206. * 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.
  29207. */
  29208. shadowsExposure: number;
  29209. /**
  29210. * Returns the class name
  29211. * @returns The class name
  29212. */
  29213. getClassName(): string;
  29214. /**
  29215. * Binds the color curves to the shader.
  29216. * @param colorCurves The color curve to bind
  29217. * @param effect The effect to bind to
  29218. * @param positiveUniform The positive uniform shader parameter
  29219. * @param neutralUniform The neutral uniform shader parameter
  29220. * @param negativeUniform The negative uniform shader parameter
  29221. */
  29222. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29223. /**
  29224. * Prepare the list of uniforms associated with the ColorCurves effects.
  29225. * @param uniformsList The list of uniforms used in the effect
  29226. */
  29227. static PrepareUniforms(uniformsList: string[]): void;
  29228. /**
  29229. * Returns color grading data based on a hue, density, saturation and exposure value.
  29230. * @param filterHue The hue of the color filter.
  29231. * @param filterDensity The density of the color filter.
  29232. * @param saturation The saturation.
  29233. * @param exposure The exposure.
  29234. * @param result The result data container.
  29235. */
  29236. private getColorGradingDataToRef;
  29237. /**
  29238. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29239. * @param value The input slider value in range [-100,100].
  29240. * @returns Adjusted value.
  29241. */
  29242. private static applyColorGradingSliderNonlinear;
  29243. /**
  29244. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29245. * @param hue The hue (H) input.
  29246. * @param saturation The saturation (S) input.
  29247. * @param brightness The brightness (B) input.
  29248. * @result An RGBA color represented as Vector4.
  29249. */
  29250. private static fromHSBToRef;
  29251. /**
  29252. * Returns a value clamped between min and max
  29253. * @param value The value to clamp
  29254. * @param min The minimum of value
  29255. * @param max The maximum of value
  29256. * @returns The clamped value.
  29257. */
  29258. private static clamp;
  29259. /**
  29260. * Clones the current color curve instance.
  29261. * @return The cloned curves
  29262. */
  29263. clone(): ColorCurves;
  29264. /**
  29265. * Serializes the current color curve instance to a json representation.
  29266. * @return a JSON representation
  29267. */
  29268. serialize(): any;
  29269. /**
  29270. * Parses the color curve from a json representation.
  29271. * @param source the JSON source to parse
  29272. * @return The parsed curves
  29273. */
  29274. static Parse(source: any): ColorCurves;
  29275. }
  29276. }
  29277. declare module BABYLON {
  29278. /**
  29279. * Interface to follow in your material defines to integrate easily the
  29280. * Image proccessing functions.
  29281. * @hidden
  29282. */
  29283. export interface IImageProcessingConfigurationDefines {
  29284. IMAGEPROCESSING: boolean;
  29285. VIGNETTE: boolean;
  29286. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29287. VIGNETTEBLENDMODEOPAQUE: boolean;
  29288. TONEMAPPING: boolean;
  29289. TONEMAPPING_ACES: boolean;
  29290. CONTRAST: boolean;
  29291. EXPOSURE: boolean;
  29292. COLORCURVES: boolean;
  29293. COLORGRADING: boolean;
  29294. COLORGRADING3D: boolean;
  29295. SAMPLER3DGREENDEPTH: boolean;
  29296. SAMPLER3DBGRMAP: boolean;
  29297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29298. }
  29299. /**
  29300. * @hidden
  29301. */
  29302. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29303. IMAGEPROCESSING: boolean;
  29304. VIGNETTE: boolean;
  29305. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29306. VIGNETTEBLENDMODEOPAQUE: boolean;
  29307. TONEMAPPING: boolean;
  29308. TONEMAPPING_ACES: boolean;
  29309. CONTRAST: boolean;
  29310. COLORCURVES: boolean;
  29311. COLORGRADING: boolean;
  29312. COLORGRADING3D: boolean;
  29313. SAMPLER3DGREENDEPTH: boolean;
  29314. SAMPLER3DBGRMAP: boolean;
  29315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29316. EXPOSURE: boolean;
  29317. constructor();
  29318. }
  29319. /**
  29320. * This groups together the common properties used for image processing either in direct forward pass
  29321. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29322. * or not.
  29323. */
  29324. export class ImageProcessingConfiguration {
  29325. /**
  29326. * Default tone mapping applied in BabylonJS.
  29327. */
  29328. static readonly TONEMAPPING_STANDARD: number;
  29329. /**
  29330. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29331. * to other engines rendering to increase portability.
  29332. */
  29333. static readonly TONEMAPPING_ACES: number;
  29334. /**
  29335. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29336. */
  29337. colorCurves: Nullable<ColorCurves>;
  29338. private _colorCurvesEnabled;
  29339. /**
  29340. * Gets wether the color curves effect is enabled.
  29341. */
  29342. /**
  29343. * Sets wether the color curves effect is enabled.
  29344. */
  29345. colorCurvesEnabled: boolean;
  29346. private _colorGradingTexture;
  29347. /**
  29348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29349. */
  29350. /**
  29351. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29352. */
  29353. colorGradingTexture: Nullable<BaseTexture>;
  29354. private _colorGradingEnabled;
  29355. /**
  29356. * Gets wether the color grading effect is enabled.
  29357. */
  29358. /**
  29359. * Sets wether the color grading effect is enabled.
  29360. */
  29361. colorGradingEnabled: boolean;
  29362. private _colorGradingWithGreenDepth;
  29363. /**
  29364. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29365. */
  29366. /**
  29367. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29368. */
  29369. colorGradingWithGreenDepth: boolean;
  29370. private _colorGradingBGR;
  29371. /**
  29372. * Gets wether the color grading texture contains BGR values.
  29373. */
  29374. /**
  29375. * Sets wether the color grading texture contains BGR values.
  29376. */
  29377. colorGradingBGR: boolean;
  29378. /** @hidden */ private _exposure: number;
  29379. /**
  29380. * Gets the Exposure used in the effect.
  29381. */
  29382. /**
  29383. * Sets the Exposure used in the effect.
  29384. */
  29385. exposure: number;
  29386. private _toneMappingEnabled;
  29387. /**
  29388. * Gets wether the tone mapping effect is enabled.
  29389. */
  29390. /**
  29391. * Sets wether the tone mapping effect is enabled.
  29392. */
  29393. toneMappingEnabled: boolean;
  29394. private _toneMappingType;
  29395. /**
  29396. * Gets the type of tone mapping effect.
  29397. */
  29398. /**
  29399. * Sets the type of tone mapping effect used in BabylonJS.
  29400. */
  29401. toneMappingType: number;
  29402. protected _contrast: number;
  29403. /**
  29404. * Gets the contrast used in the effect.
  29405. */
  29406. /**
  29407. * Sets the contrast used in the effect.
  29408. */
  29409. contrast: number;
  29410. /**
  29411. * Vignette stretch size.
  29412. */
  29413. vignetteStretch: number;
  29414. /**
  29415. * Vignette centre X Offset.
  29416. */
  29417. vignetteCentreX: number;
  29418. /**
  29419. * Vignette centre Y Offset.
  29420. */
  29421. vignetteCentreY: number;
  29422. /**
  29423. * Vignette weight or intensity of the vignette effect.
  29424. */
  29425. vignetteWeight: number;
  29426. /**
  29427. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29428. * if vignetteEnabled is set to true.
  29429. */
  29430. vignetteColor: Color4;
  29431. /**
  29432. * Camera field of view used by the Vignette effect.
  29433. */
  29434. vignetteCameraFov: number;
  29435. private _vignetteBlendMode;
  29436. /**
  29437. * Gets the vignette blend mode allowing different kind of effect.
  29438. */
  29439. /**
  29440. * Sets the vignette blend mode allowing different kind of effect.
  29441. */
  29442. vignetteBlendMode: number;
  29443. private _vignetteEnabled;
  29444. /**
  29445. * Gets wether the vignette effect is enabled.
  29446. */
  29447. /**
  29448. * Sets wether the vignette effect is enabled.
  29449. */
  29450. vignetteEnabled: boolean;
  29451. private _applyByPostProcess;
  29452. /**
  29453. * Gets wether the image processing is applied through a post process or not.
  29454. */
  29455. /**
  29456. * Sets wether the image processing is applied through a post process or not.
  29457. */
  29458. applyByPostProcess: boolean;
  29459. private _isEnabled;
  29460. /**
  29461. * Gets wether the image processing is enabled or not.
  29462. */
  29463. /**
  29464. * Sets wether the image processing is enabled or not.
  29465. */
  29466. isEnabled: boolean;
  29467. /**
  29468. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29469. */
  29470. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29471. /**
  29472. * Method called each time the image processing information changes requires to recompile the effect.
  29473. */
  29474. protected _updateParameters(): void;
  29475. /**
  29476. * Gets the current class name.
  29477. * @return "ImageProcessingConfiguration"
  29478. */
  29479. getClassName(): string;
  29480. /**
  29481. * Prepare the list of uniforms associated with the Image Processing effects.
  29482. * @param uniforms The list of uniforms used in the effect
  29483. * @param defines the list of defines currently in use
  29484. */
  29485. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29486. /**
  29487. * Prepare the list of samplers associated with the Image Processing effects.
  29488. * @param samplersList The list of uniforms used in the effect
  29489. * @param defines the list of defines currently in use
  29490. */
  29491. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29492. /**
  29493. * Prepare the list of defines associated to the shader.
  29494. * @param defines the list of defines to complete
  29495. * @param forPostProcess Define if we are currently in post process mode or not
  29496. */
  29497. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29498. /**
  29499. * Returns true if all the image processing information are ready.
  29500. * @returns True if ready, otherwise, false
  29501. */
  29502. isReady(): boolean;
  29503. /**
  29504. * Binds the image processing to the shader.
  29505. * @param effect The effect to bind to
  29506. * @param aspectRatio Define the current aspect ratio of the effect
  29507. */
  29508. bind(effect: Effect, aspectRatio?: number): void;
  29509. /**
  29510. * Clones the current image processing instance.
  29511. * @return The cloned image processing
  29512. */
  29513. clone(): ImageProcessingConfiguration;
  29514. /**
  29515. * Serializes the current image processing instance to a json representation.
  29516. * @return a JSON representation
  29517. */
  29518. serialize(): any;
  29519. /**
  29520. * Parses the image processing from a json representation.
  29521. * @param source the JSON source to parse
  29522. * @return The parsed image processing
  29523. */
  29524. static Parse(source: any): ImageProcessingConfiguration;
  29525. private static _VIGNETTEMODE_MULTIPLY;
  29526. private static _VIGNETTEMODE_OPAQUE;
  29527. /**
  29528. * Used to apply the vignette as a mix with the pixel color.
  29529. */
  29530. static readonly VIGNETTEMODE_MULTIPLY: number;
  29531. /**
  29532. * Used to apply the vignette as a replacement of the pixel color.
  29533. */
  29534. static readonly VIGNETTEMODE_OPAQUE: number;
  29535. }
  29536. }
  29537. declare module BABYLON {
  29538. /**
  29539. * This represents all the required information to add a fresnel effect on a material:
  29540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29541. */
  29542. export class FresnelParameters {
  29543. private _isEnabled;
  29544. /**
  29545. * Define if the fresnel effect is enable or not.
  29546. */
  29547. isEnabled: boolean;
  29548. /**
  29549. * Define the color used on edges (grazing angle)
  29550. */
  29551. leftColor: Color3;
  29552. /**
  29553. * Define the color used on center
  29554. */
  29555. rightColor: Color3;
  29556. /**
  29557. * Define bias applied to computed fresnel term
  29558. */
  29559. bias: number;
  29560. /**
  29561. * Defined the power exponent applied to fresnel term
  29562. */
  29563. power: number;
  29564. /**
  29565. * Clones the current fresnel and its valuues
  29566. * @returns a clone fresnel configuration
  29567. */
  29568. clone(): FresnelParameters;
  29569. /**
  29570. * Serializes the current fresnel parameters to a JSON representation.
  29571. * @return the JSON serialization
  29572. */
  29573. serialize(): any;
  29574. /**
  29575. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29576. * @param parsedFresnelParameters Define the JSON representation
  29577. * @returns the parsed parameters
  29578. */
  29579. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29580. }
  29581. }
  29582. declare module BABYLON {
  29583. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29584. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29585. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29586. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29587. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29588. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29589. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29590. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29591. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29592. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29593. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29594. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29595. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29596. /**
  29597. * Decorator used to define property that can be serialized as reference to a camera
  29598. * @param sourceName defines the name of the property to decorate
  29599. */
  29600. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29601. /**
  29602. * Class used to help serialization objects
  29603. */
  29604. export class SerializationHelper {
  29605. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29606. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29607. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29608. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29609. /**
  29610. * Appends the serialized animations from the source animations
  29611. * @param source Source containing the animations
  29612. * @param destination Target to store the animations
  29613. */
  29614. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29615. /**
  29616. * Static function used to serialized a specific entity
  29617. * @param entity defines the entity to serialize
  29618. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29619. * @returns a JSON compatible object representing the serialization of the entity
  29620. */
  29621. static Serialize<T>(entity: T, serializationObject?: any): any;
  29622. /**
  29623. * Creates a new entity from a serialization data object
  29624. * @param creationFunction defines a function used to instanciated the new entity
  29625. * @param source defines the source serialization data
  29626. * @param scene defines the hosting scene
  29627. * @param rootUrl defines the root url for resources
  29628. * @returns a new entity
  29629. */
  29630. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29631. /**
  29632. * Clones an object
  29633. * @param creationFunction defines the function used to instanciate the new object
  29634. * @param source defines the source object
  29635. * @returns the cloned object
  29636. */
  29637. static Clone<T>(creationFunction: () => T, source: T): T;
  29638. /**
  29639. * Instanciates a new object based on a source one (some data will be shared between both object)
  29640. * @param creationFunction defines the function used to instanciate the new object
  29641. * @param source defines the source object
  29642. * @returns the new object
  29643. */
  29644. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29645. }
  29646. }
  29647. declare module BABYLON {
  29648. /**
  29649. * This is the base class of all the camera used in the application.
  29650. * @see http://doc.babylonjs.com/features/cameras
  29651. */
  29652. export class Camera extends Node {
  29653. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29654. /**
  29655. * This is the default projection mode used by the cameras.
  29656. * It helps recreating a feeling of perspective and better appreciate depth.
  29657. * This is the best way to simulate real life cameras.
  29658. */
  29659. static readonly PERSPECTIVE_CAMERA: number;
  29660. /**
  29661. * This helps creating camera with an orthographic mode.
  29662. * 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.
  29663. */
  29664. static readonly ORTHOGRAPHIC_CAMERA: number;
  29665. /**
  29666. * This is the default FOV mode for perspective cameras.
  29667. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29668. */
  29669. static readonly FOVMODE_VERTICAL_FIXED: number;
  29670. /**
  29671. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29672. */
  29673. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29674. /**
  29675. * This specifies ther is no need for a camera rig.
  29676. * Basically only one eye is rendered corresponding to the camera.
  29677. */
  29678. static readonly RIG_MODE_NONE: number;
  29679. /**
  29680. * Simulates a camera Rig with one blue eye and one red eye.
  29681. * This can be use with 3d blue and red glasses.
  29682. */
  29683. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29684. /**
  29685. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29686. */
  29687. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29688. /**
  29689. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29690. */
  29691. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29692. /**
  29693. * Defines that both eyes of the camera will be rendered over under each other.
  29694. */
  29695. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29696. /**
  29697. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29698. */
  29699. static readonly RIG_MODE_VR: number;
  29700. /**
  29701. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29702. */
  29703. static readonly RIG_MODE_WEBVR: number;
  29704. /**
  29705. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29706. */
  29707. static readonly RIG_MODE_CUSTOM: number;
  29708. /**
  29709. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29710. */
  29711. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29712. /**
  29713. * Define the input manager associated with the camera.
  29714. */
  29715. inputs: CameraInputsManager<Camera>;
  29716. /** @hidden */ private _position: Vector3;
  29717. /**
  29718. * Define the current local position of the camera in the scene
  29719. */
  29720. position: Vector3;
  29721. /**
  29722. * The vector the camera should consider as up.
  29723. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29724. */
  29725. upVector: Vector3;
  29726. /**
  29727. * Define the current limit on the left side for an orthographic camera
  29728. * In scene unit
  29729. */
  29730. orthoLeft: Nullable<number>;
  29731. /**
  29732. * Define the current limit on the right side for an orthographic camera
  29733. * In scene unit
  29734. */
  29735. orthoRight: Nullable<number>;
  29736. /**
  29737. * Define the current limit on the bottom side for an orthographic camera
  29738. * In scene unit
  29739. */
  29740. orthoBottom: Nullable<number>;
  29741. /**
  29742. * Define the current limit on the top side for an orthographic camera
  29743. * In scene unit
  29744. */
  29745. orthoTop: Nullable<number>;
  29746. /**
  29747. * Field Of View is set in Radians. (default is 0.8)
  29748. */
  29749. fov: number;
  29750. /**
  29751. * Define the minimum distance the camera can see from.
  29752. * This is important to note that the depth buffer are not infinite and the closer it starts
  29753. * the more your scene might encounter depth fighting issue.
  29754. */
  29755. minZ: number;
  29756. /**
  29757. * Define the maximum distance the camera can see to.
  29758. * This is important to note that the depth buffer are not infinite and the further it end
  29759. * the more your scene might encounter depth fighting issue.
  29760. */
  29761. maxZ: number;
  29762. /**
  29763. * Define the default inertia of the camera.
  29764. * This helps giving a smooth feeling to the camera movement.
  29765. */
  29766. inertia: number;
  29767. /**
  29768. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29769. */
  29770. mode: number;
  29771. /**
  29772. * Define wether the camera is intermediate.
  29773. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29774. */
  29775. isIntermediate: boolean;
  29776. /**
  29777. * Define the viewport of the camera.
  29778. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29779. */
  29780. viewport: Viewport;
  29781. /**
  29782. * Restricts the camera to viewing objects with the same layerMask.
  29783. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29784. */
  29785. layerMask: number;
  29786. /**
  29787. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29788. */
  29789. fovMode: number;
  29790. /**
  29791. * Rig mode of the camera.
  29792. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29793. * This is normally controlled byt the camera themselves as internal use.
  29794. */
  29795. cameraRigMode: number;
  29796. /**
  29797. * Defines the distance between both "eyes" in case of a RIG
  29798. */
  29799. interaxialDistance: number;
  29800. /**
  29801. * Defines if stereoscopic rendering is done side by side or over under.
  29802. */
  29803. isStereoscopicSideBySide: boolean;
  29804. /**
  29805. * 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
  29806. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29807. * else in the scene.
  29808. */
  29809. customRenderTargets: RenderTargetTexture[];
  29810. /**
  29811. * When set, the camera will render to this render target instead of the default canvas
  29812. */
  29813. outputRenderTarget: Nullable<RenderTargetTexture>;
  29814. /**
  29815. * Observable triggered when the camera view matrix has changed.
  29816. */
  29817. onViewMatrixChangedObservable: Observable<Camera>;
  29818. /**
  29819. * Observable triggered when the camera Projection matrix has changed.
  29820. */
  29821. onProjectionMatrixChangedObservable: Observable<Camera>;
  29822. /**
  29823. * Observable triggered when the inputs have been processed.
  29824. */
  29825. onAfterCheckInputsObservable: Observable<Camera>;
  29826. /**
  29827. * Observable triggered when reset has been called and applied to the camera.
  29828. */
  29829. onRestoreStateObservable: Observable<Camera>;
  29830. /** @hidden */ private _cameraRigParams: any;
  29831. /** @hidden */ private _rigCameras: Camera[];
  29832. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  29833. protected _webvrViewMatrix: Matrix;
  29834. /** @hidden */ private _skipRendering: boolean;
  29835. /** @hidden */ private _projectionMatrix: Matrix;
  29836. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  29837. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  29838. protected _globalPosition: Vector3;
  29839. /** hidden */ private _computedViewMatrix: Matrix;
  29840. private _doNotComputeProjectionMatrix;
  29841. private _transformMatrix;
  29842. private _frustumPlanes;
  29843. private _refreshFrustumPlanes;
  29844. private _storedFov;
  29845. private _stateStored;
  29846. /**
  29847. * Instantiates a new camera object.
  29848. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29849. * @see http://doc.babylonjs.com/features/cameras
  29850. * @param name Defines the name of the camera in the scene
  29851. * @param position Defines the position of the camera
  29852. * @param scene Defines the scene the camera belongs too
  29853. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29854. */
  29855. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29856. /**
  29857. * Store current camera state (fov, position, etc..)
  29858. * @returns the camera
  29859. */
  29860. storeState(): Camera;
  29861. /**
  29862. * Restores the camera state values if it has been stored. You must call storeState() first
  29863. */
  29864. protected _restoreStateValues(): boolean;
  29865. /**
  29866. * Restored camera state. You must call storeState() first.
  29867. * @returns true if restored and false otherwise
  29868. */
  29869. restoreState(): boolean;
  29870. /**
  29871. * Gets the class name of the camera.
  29872. * @returns the class name
  29873. */
  29874. getClassName(): string;
  29875. /** @hidden */ protected readonly _isCamera: boolean;
  29876. /**
  29877. * Gets a string representation of the camera useful for debug purpose.
  29878. * @param fullDetails Defines that a more verboe level of logging is required
  29879. * @returns the string representation
  29880. */
  29881. toString(fullDetails?: boolean): string;
  29882. /**
  29883. * Gets the current world space position of the camera.
  29884. */
  29885. readonly globalPosition: Vector3;
  29886. /**
  29887. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29888. * @returns the active meshe list
  29889. */
  29890. getActiveMeshes(): SmartArray<AbstractMesh>;
  29891. /**
  29892. * Check wether a mesh is part of the current active mesh list of the camera
  29893. * @param mesh Defines the mesh to check
  29894. * @returns true if active, false otherwise
  29895. */
  29896. isActiveMesh(mesh: Mesh): boolean;
  29897. /**
  29898. * Is this camera ready to be used/rendered
  29899. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29900. * @return true if the camera is ready
  29901. */
  29902. isReady(completeCheck?: boolean): boolean;
  29903. /** @hidden */ private _initCache(): void;
  29904. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  29905. /** @hidden */ private _isSynchronized(): boolean;
  29906. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  29907. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  29908. /**
  29909. * Attach the input controls to a specific dom element to get the input from.
  29910. * @param element Defines the element the controls should be listened from
  29911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29912. */
  29913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29914. /**
  29915. * Detach the current controls from the specified dom element.
  29916. * @param element Defines the element to stop listening the inputs from
  29917. */
  29918. detachControl(element: HTMLElement): void;
  29919. /**
  29920. * Update the camera state according to the different inputs gathered during the frame.
  29921. */
  29922. update(): void;
  29923. /** @hidden */ private _checkInputs(): void;
  29924. /** @hidden */
  29925. readonly rigCameras: Camera[];
  29926. /**
  29927. * Gets the post process used by the rig cameras
  29928. */
  29929. readonly rigPostProcess: Nullable<PostProcess>;
  29930. /**
  29931. * Internal, gets the first post proces.
  29932. * @returns the first post process to be run on this camera.
  29933. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  29934. private _cascadePostProcessesToRigCams;
  29935. /**
  29936. * Attach a post process to the camera.
  29937. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29938. * @param postProcess The post process to attach to the camera
  29939. * @param insertAt The position of the post process in case several of them are in use in the scene
  29940. * @returns the position the post process has been inserted at
  29941. */
  29942. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29943. /**
  29944. * Detach a post process to the camera.
  29945. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29946. * @param postProcess The post process to detach from the camera
  29947. */
  29948. detachPostProcess(postProcess: PostProcess): void;
  29949. /**
  29950. * Gets the current world matrix of the camera
  29951. */
  29952. getWorldMatrix(): Matrix;
  29953. /** @hidden */ private _getViewMatrix(): Matrix;
  29954. /**
  29955. * Gets the current view matrix of the camera.
  29956. * @param force forces the camera to recompute the matrix without looking at the cached state
  29957. * @returns the view matrix
  29958. */
  29959. getViewMatrix(force?: boolean): Matrix;
  29960. /**
  29961. * Freeze the projection matrix.
  29962. * It will prevent the cache check of the camera projection compute and can speed up perf
  29963. * if no parameter of the camera are meant to change
  29964. * @param projection Defines manually a projection if necessary
  29965. */
  29966. freezeProjectionMatrix(projection?: Matrix): void;
  29967. /**
  29968. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29969. */
  29970. unfreezeProjectionMatrix(): void;
  29971. /**
  29972. * Gets the current projection matrix of the camera.
  29973. * @param force forces the camera to recompute the matrix without looking at the cached state
  29974. * @returns the projection matrix
  29975. */
  29976. getProjectionMatrix(force?: boolean): Matrix;
  29977. /**
  29978. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29979. * @returns a Matrix
  29980. */
  29981. getTransformationMatrix(): Matrix;
  29982. private _updateFrustumPlanes;
  29983. /**
  29984. * Checks if a cullable object (mesh...) is in the camera frustum
  29985. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29986. * @param target The object to check
  29987. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29988. * @returns true if the object is in frustum otherwise false
  29989. */
  29990. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29991. /**
  29992. * Checks if a cullable object (mesh...) is in the camera frustum
  29993. * Unlike isInFrustum this cheks the full bounding box
  29994. * @param target The object to check
  29995. * @returns true if the object is in frustum otherwise false
  29996. */
  29997. isCompletelyInFrustum(target: ICullable): boolean;
  29998. /**
  29999. * Gets a ray in the forward direction from the camera.
  30000. * @param length Defines the length of the ray to create
  30001. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30002. * @param origin Defines the start point of the ray which defaults to the camera position
  30003. * @returns the forward ray
  30004. */
  30005. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30006. /**
  30007. * Releases resources associated with this node.
  30008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30010. */
  30011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30012. /** @hidden */ private _isLeftCamera: boolean;
  30013. /**
  30014. * Gets the left camera of a rig setup in case of Rigged Camera
  30015. */
  30016. readonly isLeftCamera: boolean;
  30017. /** @hidden */ private _isRightCamera: boolean;
  30018. /**
  30019. * Gets the right camera of a rig setup in case of Rigged Camera
  30020. */
  30021. readonly isRightCamera: boolean;
  30022. /**
  30023. * Gets the left camera of a rig setup in case of Rigged Camera
  30024. */
  30025. readonly leftCamera: Nullable<FreeCamera>;
  30026. /**
  30027. * Gets the right camera of a rig setup in case of Rigged Camera
  30028. */
  30029. readonly rightCamera: Nullable<FreeCamera>;
  30030. /**
  30031. * Gets the left camera target of a rig setup in case of Rigged Camera
  30032. * @returns the target position
  30033. */
  30034. getLeftTarget(): Nullable<Vector3>;
  30035. /**
  30036. * Gets the right camera target of a rig setup in case of Rigged Camera
  30037. * @returns the target position
  30038. */
  30039. getRightTarget(): Nullable<Vector3>;
  30040. /**
  30041. * @hidden
  30042. */
  30043. setCameraRigMode(mode: number, rigParams: any): void;
  30044. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30045. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30046. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30047. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30048. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  30049. protected _updateCameraRotationMatrix(): void;
  30050. protected _updateWebVRCameraRotationMatrix(): void;
  30051. /**
  30052. * This function MUST be overwritten by the different WebVR cameras available.
  30053. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30054. * @hidden
  30055. */ private _getWebVRProjectionMatrix(): Matrix;
  30056. /**
  30057. * This function MUST be overwritten by the different WebVR cameras available.
  30058. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30059. * @hidden
  30060. */ private _getWebVRViewMatrix(): Matrix;
  30061. /** @hidden */
  30062. setCameraRigParameter(name: string, value: any): void;
  30063. /**
  30064. * needs to be overridden by children so sub has required properties to be copied
  30065. * @hidden
  30066. */
  30067. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30068. /**
  30069. * May need to be overridden by children
  30070. * @hidden
  30071. */ private _updateRigCameras(): void;
  30072. /** @hidden */ private _setupInputs(): void;
  30073. /**
  30074. * Serialiaze the camera setup to a json represention
  30075. * @returns the JSON representation
  30076. */
  30077. serialize(): any;
  30078. /**
  30079. * Clones the current camera.
  30080. * @param name The cloned camera name
  30081. * @returns the cloned camera
  30082. */
  30083. clone(name: string): Camera;
  30084. /**
  30085. * Gets the direction of the camera relative to a given local axis.
  30086. * @param localAxis Defines the reference axis to provide a relative direction.
  30087. * @return the direction
  30088. */
  30089. getDirection(localAxis: Vector3): Vector3;
  30090. /**
  30091. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30092. * @param localAxis Defines the reference axis to provide a relative direction.
  30093. * @param result Defines the vector to store the result in
  30094. */
  30095. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30096. /**
  30097. * Gets a camera constructor for a given camera type
  30098. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30099. * @param name The name of the camera the result will be able to instantiate
  30100. * @param scene The scene the result will construct the camera in
  30101. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30102. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30103. * @returns a factory method to construc the camera
  30104. */
  30105. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30106. /**
  30107. * Compute the world matrix of the camera.
  30108. * @returns the camera workd matrix
  30109. */
  30110. computeWorldMatrix(): Matrix;
  30111. /**
  30112. * Parse a JSON and creates the camera from the parsed information
  30113. * @param parsedCamera The JSON to parse
  30114. * @param scene The scene to instantiate the camera in
  30115. * @returns the newly constructed camera
  30116. */
  30117. static Parse(parsedCamera: any, scene: Scene): Camera;
  30118. }
  30119. }
  30120. declare module BABYLON {
  30121. /**
  30122. * Interface for any object that can request an animation frame
  30123. */
  30124. export interface ICustomAnimationFrameRequester {
  30125. /**
  30126. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30127. */
  30128. renderFunction?: Function;
  30129. /**
  30130. * Called to request the next frame to render to
  30131. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30132. */
  30133. requestAnimationFrame: Function;
  30134. /**
  30135. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30136. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30137. */
  30138. requestID?: number;
  30139. }
  30140. /**
  30141. * Interface containing an array of animations
  30142. */
  30143. export interface IAnimatable {
  30144. /**
  30145. * Array of animations
  30146. */
  30147. animations: Nullable<Array<Animation>>;
  30148. }
  30149. /** Interface used by value gradients (color, factor, ...) */
  30150. export interface IValueGradient {
  30151. /**
  30152. * Gets or sets the gradient value (between 0 and 1)
  30153. */
  30154. gradient: number;
  30155. }
  30156. /** Class used to store color4 gradient */
  30157. export class ColorGradient implements IValueGradient {
  30158. /**
  30159. * Gets or sets the gradient value (between 0 and 1)
  30160. */
  30161. gradient: number;
  30162. /**
  30163. * Gets or sets first associated color
  30164. */
  30165. color1: Color4;
  30166. /**
  30167. * Gets or sets second associated color
  30168. */
  30169. color2?: Color4;
  30170. /**
  30171. * Will get a color picked randomly between color1 and color2.
  30172. * If color2 is undefined then color1 will be used
  30173. * @param result defines the target Color4 to store the result in
  30174. */
  30175. getColorToRef(result: Color4): void;
  30176. }
  30177. /** Class used to store color 3 gradient */
  30178. export class Color3Gradient implements IValueGradient {
  30179. /**
  30180. * Gets or sets the gradient value (between 0 and 1)
  30181. */
  30182. gradient: number;
  30183. /**
  30184. * Gets or sets the associated color
  30185. */
  30186. color: Color3;
  30187. }
  30188. /** Class used to store factor gradient */
  30189. export class FactorGradient implements IValueGradient {
  30190. /**
  30191. * Gets or sets the gradient value (between 0 and 1)
  30192. */
  30193. gradient: number;
  30194. /**
  30195. * Gets or sets first associated factor
  30196. */
  30197. factor1: number;
  30198. /**
  30199. * Gets or sets second associated factor
  30200. */
  30201. factor2?: number;
  30202. /**
  30203. * Will get a number picked randomly between factor1 and factor2.
  30204. * If factor2 is undefined then factor1 will be used
  30205. * @returns the picked number
  30206. */
  30207. getFactor(): number;
  30208. }
  30209. /**
  30210. * @ignore
  30211. * Application error to support additional information when loading a file
  30212. */
  30213. export class LoadFileError extends Error {
  30214. /** defines the optional web request */
  30215. request?: WebRequest | undefined;
  30216. private static _setPrototypeOf;
  30217. /**
  30218. * Creates a new LoadFileError
  30219. * @param message defines the message of the error
  30220. * @param request defines the optional web request
  30221. */
  30222. constructor(message: string,
  30223. /** defines the optional web request */
  30224. request?: WebRequest | undefined);
  30225. }
  30226. /**
  30227. * Class used to define a retry strategy when error happens while loading assets
  30228. */
  30229. export class RetryStrategy {
  30230. /**
  30231. * Function used to defines an exponential back off strategy
  30232. * @param maxRetries defines the maximum number of retries (3 by default)
  30233. * @param baseInterval defines the interval between retries
  30234. * @returns the strategy function to use
  30235. */
  30236. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30237. }
  30238. /**
  30239. * File request interface
  30240. */
  30241. export interface IFileRequest {
  30242. /**
  30243. * Raised when the request is complete (success or error).
  30244. */
  30245. onCompleteObservable: Observable<IFileRequest>;
  30246. /**
  30247. * Aborts the request for a file.
  30248. */
  30249. abort: () => void;
  30250. }
  30251. /**
  30252. * Class containing a set of static utilities functions
  30253. */
  30254. export class Tools {
  30255. /**
  30256. * Gets or sets the base URL to use to load assets
  30257. */
  30258. static BaseUrl: string;
  30259. /**
  30260. * Enable/Disable Custom HTTP Request Headers globally.
  30261. * default = false
  30262. * @see CustomRequestHeaders
  30263. */
  30264. static UseCustomRequestHeaders: boolean;
  30265. /**
  30266. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30267. * i.e. when loading files, where the server/service expects an Authorization header
  30268. */
  30269. static CustomRequestHeaders: {
  30270. [key: string]: string;
  30271. };
  30272. /**
  30273. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30274. */
  30275. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30276. /**
  30277. * Default behaviour for cors in the application.
  30278. * It can be a string if the expected behavior is identical in the entire app.
  30279. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30280. */
  30281. static CorsBehavior: string | ((url: string | string[]) => string);
  30282. /**
  30283. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30284. * @ignorenaming
  30285. */
  30286. static UseFallbackTexture: boolean;
  30287. /**
  30288. * Use this object to register external classes like custom textures or material
  30289. * to allow the laoders to instantiate them
  30290. */
  30291. static RegisteredExternalClasses: {
  30292. [key: string]: Object;
  30293. };
  30294. /**
  30295. * Texture content used if a texture cannot loaded
  30296. * @ignorenaming
  30297. */
  30298. static fallbackTexture: string;
  30299. /**
  30300. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30301. * @param u defines the coordinate on X axis
  30302. * @param v defines the coordinate on Y axis
  30303. * @param width defines the width of the source data
  30304. * @param height defines the height of the source data
  30305. * @param pixels defines the source byte array
  30306. * @param color defines the output color
  30307. */
  30308. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30309. /**
  30310. * Interpolates between a and b via alpha
  30311. * @param a The lower value (returned when alpha = 0)
  30312. * @param b The upper value (returned when alpha = 1)
  30313. * @param alpha The interpolation-factor
  30314. * @return The mixed value
  30315. */
  30316. static Mix(a: number, b: number, alpha: number): number;
  30317. /**
  30318. * Tries to instantiate a new object from a given class name
  30319. * @param className defines the class name to instantiate
  30320. * @returns the new object or null if the system was not able to do the instantiation
  30321. */
  30322. static Instantiate(className: string): any;
  30323. /**
  30324. * Provides a slice function that will work even on IE
  30325. * @param data defines the array to slice
  30326. * @param start defines the start of the data (optional)
  30327. * @param end defines the end of the data (optional)
  30328. * @returns the new sliced array
  30329. */
  30330. static Slice<T>(data: T, start?: number, end?: number): T;
  30331. /**
  30332. * Polyfill for setImmediate
  30333. * @param action defines the action to execute after the current execution block
  30334. */
  30335. static SetImmediate(action: () => void): void;
  30336. /**
  30337. * Function indicating if a number is an exponent of 2
  30338. * @param value defines the value to test
  30339. * @returns true if the value is an exponent of 2
  30340. */
  30341. static IsExponentOfTwo(value: number): boolean;
  30342. private static _tmpFloatArray;
  30343. /**
  30344. * Returns the nearest 32-bit single precision float representation of a Number
  30345. * @param value A Number. If the parameter is of a different type, it will get converted
  30346. * to a number or to NaN if it cannot be converted
  30347. * @returns number
  30348. */
  30349. static FloatRound(value: number): number;
  30350. /**
  30351. * Find the next highest power of two.
  30352. * @param x Number to start search from.
  30353. * @return Next highest power of two.
  30354. */
  30355. static CeilingPOT(x: number): number;
  30356. /**
  30357. * Find the next lowest power of two.
  30358. * @param x Number to start search from.
  30359. * @return Next lowest power of two.
  30360. */
  30361. static FloorPOT(x: number): number;
  30362. /**
  30363. * Find the nearest power of two.
  30364. * @param x Number to start search from.
  30365. * @return Next nearest power of two.
  30366. */
  30367. static NearestPOT(x: number): number;
  30368. /**
  30369. * Get the closest exponent of two
  30370. * @param value defines the value to approximate
  30371. * @param max defines the maximum value to return
  30372. * @param mode defines how to define the closest value
  30373. * @returns closest exponent of two of the given value
  30374. */
  30375. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30376. /**
  30377. * Extracts the filename from a path
  30378. * @param path defines the path to use
  30379. * @returns the filename
  30380. */
  30381. static GetFilename(path: string): string;
  30382. /**
  30383. * Extracts the "folder" part of a path (everything before the filename).
  30384. * @param uri The URI to extract the info from
  30385. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30386. * @returns The "folder" part of the path
  30387. */
  30388. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30389. /**
  30390. * Extracts text content from a DOM element hierarchy
  30391. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30392. */
  30393. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30394. /**
  30395. * Convert an angle in radians to degrees
  30396. * @param angle defines the angle to convert
  30397. * @returns the angle in degrees
  30398. */
  30399. static ToDegrees(angle: number): number;
  30400. /**
  30401. * Convert an angle in degrees to radians
  30402. * @param angle defines the angle to convert
  30403. * @returns the angle in radians
  30404. */
  30405. static ToRadians(angle: number): number;
  30406. /**
  30407. * Encode a buffer to a base64 string
  30408. * @param buffer defines the buffer to encode
  30409. * @returns the encoded string
  30410. */
  30411. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30412. /**
  30413. * Extracts minimum and maximum values from a list of indexed positions
  30414. * @param positions defines the positions to use
  30415. * @param indices defines the indices to the positions
  30416. * @param indexStart defines the start index
  30417. * @param indexCount defines the end index
  30418. * @param bias defines bias value to add to the result
  30419. * @return minimum and maximum values
  30420. */
  30421. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30422. minimum: Vector3;
  30423. maximum: Vector3;
  30424. };
  30425. /**
  30426. * Extracts minimum and maximum values from a list of positions
  30427. * @param positions defines the positions to use
  30428. * @param start defines the start index in the positions array
  30429. * @param count defines the number of positions to handle
  30430. * @param bias defines bias value to add to the result
  30431. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30432. * @return minimum and maximum values
  30433. */
  30434. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30435. minimum: Vector3;
  30436. maximum: Vector3;
  30437. };
  30438. /**
  30439. * Returns an array if obj is not an array
  30440. * @param obj defines the object to evaluate as an array
  30441. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30442. * @returns either obj directly if obj is an array or a new array containing obj
  30443. */
  30444. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30445. /**
  30446. * Gets the pointer prefix to use
  30447. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30448. */
  30449. static GetPointerPrefix(): string;
  30450. /**
  30451. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30452. * @param func - the function to be called
  30453. * @param requester - the object that will request the next frame. Falls back to window.
  30454. * @returns frame number
  30455. */
  30456. static QueueNewFrame(func: () => void, requester?: any): number;
  30457. /**
  30458. * Ask the browser to promote the current element to fullscreen rendering mode
  30459. * @param element defines the DOM element to promote
  30460. */
  30461. static RequestFullscreen(element: HTMLElement): void;
  30462. /**
  30463. * Asks the browser to exit fullscreen mode
  30464. */
  30465. static ExitFullscreen(): void;
  30466. /**
  30467. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30468. * @param url define the url we are trying
  30469. * @param element define the dom element where to configure the cors policy
  30470. */
  30471. static SetCorsBehavior(url: string | string[], element: {
  30472. crossOrigin: string | null;
  30473. }): void;
  30474. /**
  30475. * Removes unwanted characters from an url
  30476. * @param url defines the url to clean
  30477. * @returns the cleaned url
  30478. */
  30479. static CleanUrl(url: string): string;
  30480. /**
  30481. * Gets or sets a function used to pre-process url before using them to load assets
  30482. */
  30483. static PreprocessUrl: (url: string) => string;
  30484. /**
  30485. * Loads an image as an HTMLImageElement.
  30486. * @param input url string, ArrayBuffer, or Blob to load
  30487. * @param onLoad callback called when the image successfully loads
  30488. * @param onError callback called when the image fails to load
  30489. * @param offlineProvider offline provider for caching
  30490. * @returns the HTMLImageElement of the loaded image
  30491. */
  30492. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30493. /**
  30494. * Loads a file
  30495. * @param url url string, ArrayBuffer, or Blob to load
  30496. * @param onSuccess callback called when the file successfully loads
  30497. * @param onProgress callback called while file is loading (if the server supports this mode)
  30498. * @param offlineProvider defines the offline provider for caching
  30499. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30500. * @param onError callback called when the file fails to load
  30501. * @returns a file request object
  30502. */
  30503. 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;
  30504. /**
  30505. * Load a script (identified by an url). When the url returns, the
  30506. * content of this file is added into a new script element, attached to the DOM (body element)
  30507. * @param scriptUrl defines the url of the script to laod
  30508. * @param onSuccess defines the callback called when the script is loaded
  30509. * @param onError defines the callback to call if an error occurs
  30510. * @param scriptId defines the id of the script element
  30511. */
  30512. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30513. /**
  30514. * Load an asynchronous script (identified by an url). When the url returns, the
  30515. * content of this file is added into a new script element, attached to the DOM (body element)
  30516. * @param scriptUrl defines the url of the script to laod
  30517. * @param scriptId defines the id of the script element
  30518. * @returns a promise request object
  30519. */
  30520. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30521. /**
  30522. * Loads a file from a blob
  30523. * @param fileToLoad defines the blob to use
  30524. * @param callback defines the callback to call when data is loaded
  30525. * @param progressCallback defines the callback to call during loading process
  30526. * @returns a file request object
  30527. */
  30528. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30529. /**
  30530. * Loads a file
  30531. * @param fileToLoad defines the file to load
  30532. * @param callback defines the callback to call when data is loaded
  30533. * @param progressCallBack defines the callback to call during loading process
  30534. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30535. * @returns a file request object
  30536. */
  30537. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30538. /**
  30539. * Creates a data url from a given string content
  30540. * @param content defines the content to convert
  30541. * @returns the new data url link
  30542. */
  30543. static FileAsURL(content: string): string;
  30544. /**
  30545. * Format the given number to a specific decimal format
  30546. * @param value defines the number to format
  30547. * @param decimals defines the number of decimals to use
  30548. * @returns the formatted string
  30549. */
  30550. static Format(value: number, decimals?: number): string;
  30551. /**
  30552. * Checks if a given vector is inside a specific range
  30553. * @param v defines the vector to test
  30554. * @param min defines the minimum range
  30555. * @param max defines the maximum range
  30556. */
  30557. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30558. /**
  30559. * Tries to copy an object by duplicating every property
  30560. * @param source defines the source object
  30561. * @param destination defines the target object
  30562. * @param doNotCopyList defines a list of properties to avoid
  30563. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30564. */
  30565. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30566. /**
  30567. * Gets a boolean indicating if the given object has no own property
  30568. * @param obj defines the object to test
  30569. * @returns true if object has no own property
  30570. */
  30571. static IsEmpty(obj: any): boolean;
  30572. /**
  30573. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30574. * @param str Source string
  30575. * @param suffix Suffix to search for in the source string
  30576. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30577. */
  30578. static EndsWith(str: string, suffix: string): boolean;
  30579. /**
  30580. * Function used to register events at window level
  30581. * @param events defines the events to register
  30582. */
  30583. static RegisterTopRootEvents(events: {
  30584. name: string;
  30585. handler: Nullable<(e: FocusEvent) => any>;
  30586. }[]): void;
  30587. /**
  30588. * Function used to unregister events from window level
  30589. * @param events defines the events to unregister
  30590. */
  30591. static UnregisterTopRootEvents(events: {
  30592. name: string;
  30593. handler: Nullable<(e: FocusEvent) => any>;
  30594. }[]): void;
  30595. /**
  30596. * @ignore
  30597. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30598. /**
  30599. * Dumps the current bound framebuffer
  30600. * @param width defines the rendering width
  30601. * @param height defines the rendering height
  30602. * @param engine defines the hosting engine
  30603. * @param successCallback defines the callback triggered once the data are available
  30604. * @param mimeType defines the mime type of the result
  30605. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30606. */
  30607. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30608. /**
  30609. * Converts the canvas data to blob.
  30610. * This acts as a polyfill for browsers not supporting the to blob function.
  30611. * @param canvas Defines the canvas to extract the data from
  30612. * @param successCallback Defines the callback triggered once the data are available
  30613. * @param mimeType Defines the mime type of the result
  30614. */
  30615. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30616. /**
  30617. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30618. * @param successCallback defines the callback triggered once the data are available
  30619. * @param mimeType defines the mime type of the result
  30620. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30621. */
  30622. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30623. /**
  30624. * Downloads a blob in the browser
  30625. * @param blob defines the blob to download
  30626. * @param fileName defines the name of the downloaded file
  30627. */
  30628. static Download(blob: Blob, fileName: string): void;
  30629. /**
  30630. * Captures a screenshot of the current rendering
  30631. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30632. * @param engine defines the rendering engine
  30633. * @param camera defines the source camera
  30634. * @param size This parameter can be set to a single number or to an object with the
  30635. * following (optional) properties: precision, width, height. If a single number is passed,
  30636. * it will be used for both width and height. If an object is passed, the screenshot size
  30637. * will be derived from the parameters. The precision property is a multiplier allowing
  30638. * rendering at a higher or lower resolution
  30639. * @param successCallback defines the callback receives a single parameter which contains the
  30640. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30641. * src parameter of an <img> to display it
  30642. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30643. * Check your browser for supported MIME types
  30644. */
  30645. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30646. /**
  30647. * Generates an image screenshot from the specified camera.
  30648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30649. * @param engine The engine to use for rendering
  30650. * @param camera The camera to use for rendering
  30651. * @param size This parameter can be set to a single number or to an object with the
  30652. * following (optional) properties: precision, width, height. If a single number is passed,
  30653. * it will be used for both width and height. If an object is passed, the screenshot size
  30654. * will be derived from the parameters. The precision property is a multiplier allowing
  30655. * rendering at a higher or lower resolution
  30656. * @param successCallback The callback receives a single parameter which contains the
  30657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30658. * src parameter of an <img> to display it
  30659. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30660. * Check your browser for supported MIME types
  30661. * @param samples Texture samples (default: 1)
  30662. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30663. * @param fileName A name for for the downloaded file.
  30664. */
  30665. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30666. /**
  30667. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30668. * Be aware Math.random() could cause collisions, but:
  30669. * "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"
  30670. * @returns a pseudo random id
  30671. */
  30672. static RandomId(): string;
  30673. /**
  30674. * Test if the given uri is a base64 string
  30675. * @param uri The uri to test
  30676. * @return True if the uri is a base64 string or false otherwise
  30677. */
  30678. static IsBase64(uri: string): boolean;
  30679. /**
  30680. * Decode the given base64 uri.
  30681. * @param uri The uri to decode
  30682. * @return The decoded base64 data.
  30683. */
  30684. static DecodeBase64(uri: string): ArrayBuffer;
  30685. /**
  30686. * Gets the absolute url.
  30687. * @param url the input url
  30688. * @return the absolute url
  30689. */
  30690. static GetAbsoluteUrl(url: string): string;
  30691. /**
  30692. * No log
  30693. */
  30694. static readonly NoneLogLevel: number;
  30695. /**
  30696. * Only message logs
  30697. */
  30698. static readonly MessageLogLevel: number;
  30699. /**
  30700. * Only warning logs
  30701. */
  30702. static readonly WarningLogLevel: number;
  30703. /**
  30704. * Only error logs
  30705. */
  30706. static readonly ErrorLogLevel: number;
  30707. /**
  30708. * All logs
  30709. */
  30710. static readonly AllLogLevel: number;
  30711. /**
  30712. * Gets a value indicating the number of loading errors
  30713. * @ignorenaming
  30714. */
  30715. static readonly errorsCount: number;
  30716. /**
  30717. * Callback called when a new log is added
  30718. */
  30719. static OnNewCacheEntry: (entry: string) => void;
  30720. /**
  30721. * Log a message to the console
  30722. * @param message defines the message to log
  30723. */
  30724. static Log(message: string): void;
  30725. /**
  30726. * Write a warning message to the console
  30727. * @param message defines the message to log
  30728. */
  30729. static Warn(message: string): void;
  30730. /**
  30731. * Write an error message to the console
  30732. * @param message defines the message to log
  30733. */
  30734. static Error(message: string): void;
  30735. /**
  30736. * Gets current log cache (list of logs)
  30737. */
  30738. static readonly LogCache: string;
  30739. /**
  30740. * Clears the log cache
  30741. */
  30742. static ClearLogCache(): void;
  30743. /**
  30744. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30745. */
  30746. static LogLevels: number;
  30747. /**
  30748. * Checks if the loaded document was accessed via `file:`-Protocol.
  30749. * @returns boolean
  30750. */
  30751. static IsFileURL(): boolean;
  30752. /**
  30753. * Checks if the window object exists
  30754. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30755. */
  30756. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30757. /**
  30758. * No performance log
  30759. */
  30760. static readonly PerformanceNoneLogLevel: number;
  30761. /**
  30762. * Use user marks to log performance
  30763. */
  30764. static readonly PerformanceUserMarkLogLevel: number;
  30765. /**
  30766. * Log performance to the console
  30767. */
  30768. static readonly PerformanceConsoleLogLevel: number;
  30769. private static _performance;
  30770. /**
  30771. * Sets the current performance log level
  30772. */
  30773. static PerformanceLogLevel: number;
  30774. private static _StartPerformanceCounterDisabled;
  30775. private static _EndPerformanceCounterDisabled;
  30776. private static _StartUserMark;
  30777. private static _EndUserMark;
  30778. private static _StartPerformanceConsole;
  30779. private static _EndPerformanceConsole;
  30780. /**
  30781. * Starts a performance counter
  30782. */
  30783. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30784. /**
  30785. * Ends a specific performance coutner
  30786. */
  30787. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30788. /**
  30789. * Gets either window.performance.now() if supported or Date.now() else
  30790. */
  30791. static readonly Now: number;
  30792. /**
  30793. * This method will return the name of the class used to create the instance of the given object.
  30794. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30795. * @param object the object to get the class name from
  30796. * @param isType defines if the object is actually a type
  30797. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30798. */
  30799. static GetClassName(object: any, isType?: boolean): string;
  30800. /**
  30801. * Gets the first element of an array satisfying a given predicate
  30802. * @param array defines the array to browse
  30803. * @param predicate defines the predicate to use
  30804. * @returns null if not found or the element
  30805. */
  30806. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30807. /**
  30808. * This method will return the name of the full name of the class, including its owning module (if any).
  30809. * 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).
  30810. * @param object the object to get the class name from
  30811. * @param isType defines if the object is actually a type
  30812. * @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.
  30813. * @ignorenaming
  30814. */
  30815. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30816. /**
  30817. * Returns a promise that resolves after the given amount of time.
  30818. * @param delay Number of milliseconds to delay
  30819. * @returns Promise that resolves after the given amount of time
  30820. */
  30821. static DelayAsync(delay: number): Promise<void>;
  30822. /**
  30823. * Gets the current gradient from an array of IValueGradient
  30824. * @param ratio defines the current ratio to get
  30825. * @param gradients defines the array of IValueGradient
  30826. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30827. */
  30828. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30829. }
  30830. /**
  30831. * This class is used to track a performance counter which is number based.
  30832. * The user has access to many properties which give statistics of different nature.
  30833. *
  30834. * The implementer can track two kinds of Performance Counter: time and count.
  30835. * 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.
  30836. * 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.
  30837. */
  30838. export class PerfCounter {
  30839. /**
  30840. * Gets or sets a global boolean to turn on and off all the counters
  30841. */
  30842. static Enabled: boolean;
  30843. /**
  30844. * Returns the smallest value ever
  30845. */
  30846. readonly min: number;
  30847. /**
  30848. * Returns the biggest value ever
  30849. */
  30850. readonly max: number;
  30851. /**
  30852. * Returns the average value since the performance counter is running
  30853. */
  30854. readonly average: number;
  30855. /**
  30856. * Returns the average value of the last second the counter was monitored
  30857. */
  30858. readonly lastSecAverage: number;
  30859. /**
  30860. * Returns the current value
  30861. */
  30862. readonly current: number;
  30863. /**
  30864. * Gets the accumulated total
  30865. */
  30866. readonly total: number;
  30867. /**
  30868. * Gets the total value count
  30869. */
  30870. readonly count: number;
  30871. /**
  30872. * Creates a new counter
  30873. */
  30874. constructor();
  30875. /**
  30876. * Call this method to start monitoring a new frame.
  30877. * 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.
  30878. */
  30879. fetchNewFrame(): void;
  30880. /**
  30881. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30882. * @param newCount the count value to add to the monitored count
  30883. * @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.
  30884. */
  30885. addCount(newCount: number, fetchResult: boolean): void;
  30886. /**
  30887. * Start monitoring this performance counter
  30888. */
  30889. beginMonitoring(): void;
  30890. /**
  30891. * Compute the time lapsed since the previous beginMonitoring() call.
  30892. * @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
  30893. */
  30894. endMonitoring(newFrame?: boolean): void;
  30895. private _fetchResult;
  30896. private _startMonitoringTime;
  30897. private _min;
  30898. private _max;
  30899. private _average;
  30900. private _current;
  30901. private _totalValueCount;
  30902. private _totalAccumulated;
  30903. private _lastSecAverage;
  30904. private _lastSecAccumulated;
  30905. private _lastSecTime;
  30906. private _lastSecValueCount;
  30907. }
  30908. /**
  30909. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30910. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30911. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30912. * @param name The name of the class, case should be preserved
  30913. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30914. */
  30915. export function className(name: string, module?: string): (target: Object) => void;
  30916. /**
  30917. * An implementation of a loop for asynchronous functions.
  30918. */
  30919. export class AsyncLoop {
  30920. /**
  30921. * Defines the number of iterations for the loop
  30922. */
  30923. iterations: number;
  30924. /**
  30925. * Defines the current index of the loop.
  30926. */
  30927. index: number;
  30928. private _done;
  30929. private _fn;
  30930. private _successCallback;
  30931. /**
  30932. * Constructor.
  30933. * @param iterations the number of iterations.
  30934. * @param func the function to run each iteration
  30935. * @param successCallback the callback that will be called upon succesful execution
  30936. * @param offset starting offset.
  30937. */
  30938. constructor(
  30939. /**
  30940. * Defines the number of iterations for the loop
  30941. */
  30942. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30943. /**
  30944. * Execute the next iteration. Must be called after the last iteration was finished.
  30945. */
  30946. executeNext(): void;
  30947. /**
  30948. * Break the loop and run the success callback.
  30949. */
  30950. breakLoop(): void;
  30951. /**
  30952. * Create and run an async loop.
  30953. * @param iterations the number of iterations.
  30954. * @param fn the function to run each iteration
  30955. * @param successCallback the callback that will be called upon succesful execution
  30956. * @param offset starting offset.
  30957. * @returns the created async loop object
  30958. */
  30959. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30960. /**
  30961. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30962. * @param iterations total number of iterations
  30963. * @param syncedIterations number of synchronous iterations in each async iteration.
  30964. * @param fn the function to call each iteration.
  30965. * @param callback a success call back that will be called when iterating stops.
  30966. * @param breakFunction a break condition (optional)
  30967. * @param timeout timeout settings for the setTimeout function. default - 0.
  30968. * @returns the created async loop object
  30969. */
  30970. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30971. }
  30972. }
  30973. declare module BABYLON {
  30974. /** @hidden */
  30975. export interface ICollisionCoordinator {
  30976. createCollider(): Collider;
  30977. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30978. init(scene: Scene): void;
  30979. }
  30980. /** @hidden */
  30981. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30982. private _scene;
  30983. private _scaledPosition;
  30984. private _scaledVelocity;
  30985. private _finalPosition;
  30986. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30987. createCollider(): Collider;
  30988. init(scene: Scene): void;
  30989. private _collideWithWorld;
  30990. }
  30991. }
  30992. declare module BABYLON {
  30993. /**
  30994. * Class used to manage all inputs for the scene.
  30995. */
  30996. export class InputManager {
  30997. /** The distance in pixel that you have to move to prevent some events */
  30998. static DragMovementThreshold: number;
  30999. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31000. static LongPressDelay: number;
  31001. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31002. static DoubleClickDelay: number;
  31003. /** If you need to check double click without raising a single click at first click, enable this flag */
  31004. static ExclusiveDoubleClickMode: boolean;
  31005. private _wheelEventName;
  31006. private _onPointerMove;
  31007. private _onPointerDown;
  31008. private _onPointerUp;
  31009. private _initClickEvent;
  31010. private _initActionManager;
  31011. private _delayedSimpleClick;
  31012. private _delayedSimpleClickTimeout;
  31013. private _previousDelayedSimpleClickTimeout;
  31014. private _meshPickProceed;
  31015. private _previousButtonPressed;
  31016. private _currentPickResult;
  31017. private _previousPickResult;
  31018. private _totalPointersPressed;
  31019. private _doubleClickOccured;
  31020. private _pointerOverMesh;
  31021. private _pickedDownMesh;
  31022. private _pickedUpMesh;
  31023. private _pointerX;
  31024. private _pointerY;
  31025. private _unTranslatedPointerX;
  31026. private _unTranslatedPointerY;
  31027. private _startingPointerPosition;
  31028. private _previousStartingPointerPosition;
  31029. private _startingPointerTime;
  31030. private _previousStartingPointerTime;
  31031. private _pointerCaptures;
  31032. private _onKeyDown;
  31033. private _onKeyUp;
  31034. private _onCanvasFocusObserver;
  31035. private _onCanvasBlurObserver;
  31036. private _scene;
  31037. /**
  31038. * Creates a new InputManager
  31039. * @param scene defines the hosting scene
  31040. */
  31041. constructor(scene: Scene);
  31042. /**
  31043. * Gets the mesh that is currently under the pointer
  31044. */
  31045. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31046. /**
  31047. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31048. */
  31049. readonly unTranslatedPointer: Vector2;
  31050. /**
  31051. * Gets or sets the current on-screen X position of the pointer
  31052. */
  31053. pointerX: number;
  31054. /**
  31055. * Gets or sets the current on-screen Y position of the pointer
  31056. */
  31057. pointerY: number;
  31058. private _updatePointerPosition;
  31059. private _processPointerMove;
  31060. private _setRayOnPointerInfo;
  31061. private _checkPrePointerObservable;
  31062. /**
  31063. * Use this method to simulate a pointer move on a mesh
  31064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31067. */
  31068. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31069. /**
  31070. * Use this method to simulate a pointer down on a mesh
  31071. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31072. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31073. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31074. */
  31075. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31076. private _processPointerDown;
  31077. /** @hidden */ private _isPointerSwiping(): boolean;
  31078. /**
  31079. * Use this method to simulate a pointer up on a mesh
  31080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31083. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31084. */
  31085. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31086. private _processPointerUp;
  31087. /**
  31088. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31089. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31090. * @returns true if the pointer was captured
  31091. */
  31092. isPointerCaptured(pointerId?: number): boolean;
  31093. /**
  31094. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31095. * @param attachUp defines if you want to attach events to pointerup
  31096. * @param attachDown defines if you want to attach events to pointerdown
  31097. * @param attachMove defines if you want to attach events to pointermove
  31098. */
  31099. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31100. /**
  31101. * Detaches all event handlers
  31102. */
  31103. detachControl(): void;
  31104. /**
  31105. * Force the value of meshUnderPointer
  31106. * @param mesh defines the mesh to use
  31107. */
  31108. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31109. /**
  31110. * Gets the mesh under the pointer
  31111. * @returns a Mesh or null if no mesh is under the pointer
  31112. */
  31113. getPointerOverMesh(): Nullable<AbstractMesh>;
  31114. }
  31115. }
  31116. declare module BABYLON {
  31117. /**
  31118. * This class defines the direct association between an animation and a target
  31119. */
  31120. export class TargetedAnimation {
  31121. /**
  31122. * Animation to perform
  31123. */
  31124. animation: Animation;
  31125. /**
  31126. * Target to animate
  31127. */
  31128. target: any;
  31129. }
  31130. /**
  31131. * Use this class to create coordinated animations on multiple targets
  31132. */
  31133. export class AnimationGroup implements IDisposable {
  31134. /** The name of the animation group */
  31135. name: string;
  31136. private _scene;
  31137. private _targetedAnimations;
  31138. private _animatables;
  31139. private _from;
  31140. private _to;
  31141. private _isStarted;
  31142. private _isPaused;
  31143. private _speedRatio;
  31144. private _loopAnimation;
  31145. /**
  31146. * Gets or sets the unique id of the node
  31147. */
  31148. uniqueId: number;
  31149. /**
  31150. * This observable will notify when one animation have ended
  31151. */
  31152. onAnimationEndObservable: Observable<TargetedAnimation>;
  31153. /**
  31154. * Observer raised when one animation loops
  31155. */
  31156. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31157. /**
  31158. * This observable will notify when all animations have ended.
  31159. */
  31160. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31161. /**
  31162. * This observable will notify when all animations have paused.
  31163. */
  31164. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31165. /**
  31166. * This observable will notify when all animations are playing.
  31167. */
  31168. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31169. /**
  31170. * Gets the first frame
  31171. */
  31172. readonly from: number;
  31173. /**
  31174. * Gets the last frame
  31175. */
  31176. readonly to: number;
  31177. /**
  31178. * Define if the animations are started
  31179. */
  31180. readonly isStarted: boolean;
  31181. /**
  31182. * Gets a value indicating that the current group is playing
  31183. */
  31184. readonly isPlaying: boolean;
  31185. /**
  31186. * Gets or sets the speed ratio to use for all animations
  31187. */
  31188. /**
  31189. * Gets or sets the speed ratio to use for all animations
  31190. */
  31191. speedRatio: number;
  31192. /**
  31193. * Gets or sets if all animations should loop or not
  31194. */
  31195. loopAnimation: boolean;
  31196. /**
  31197. * Gets the targeted animations for this animation group
  31198. */
  31199. readonly targetedAnimations: Array<TargetedAnimation>;
  31200. /**
  31201. * returning the list of animatables controlled by this animation group.
  31202. */
  31203. readonly animatables: Array<Animatable>;
  31204. /**
  31205. * Instantiates a new Animation Group.
  31206. * This helps managing several animations at once.
  31207. * @see http://doc.babylonjs.com/how_to/group
  31208. * @param name Defines the name of the group
  31209. * @param scene Defines the scene the group belongs to
  31210. */
  31211. constructor(
  31212. /** The name of the animation group */
  31213. name: string, scene?: Nullable<Scene>);
  31214. /**
  31215. * Add an animation (with its target) in the group
  31216. * @param animation defines the animation we want to add
  31217. * @param target defines the target of the animation
  31218. * @returns the TargetedAnimation object
  31219. */
  31220. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31221. /**
  31222. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31223. * It can add constant keys at begin or end
  31224. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31225. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31226. * @returns the animation group
  31227. */
  31228. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31229. /**
  31230. * Start all animations on given targets
  31231. * @param loop defines if animations must loop
  31232. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31233. * @param from defines the from key (optional)
  31234. * @param to defines the to key (optional)
  31235. * @returns the current animation group
  31236. */
  31237. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31238. /**
  31239. * Pause all animations
  31240. * @returns the animation group
  31241. */
  31242. pause(): AnimationGroup;
  31243. /**
  31244. * Play all animations to initial state
  31245. * This function will start() the animations if they were not started or will restart() them if they were paused
  31246. * @param loop defines if animations must loop
  31247. * @returns the animation group
  31248. */
  31249. play(loop?: boolean): AnimationGroup;
  31250. /**
  31251. * Reset all animations to initial state
  31252. * @returns the animation group
  31253. */
  31254. reset(): AnimationGroup;
  31255. /**
  31256. * Restart animations from key 0
  31257. * @returns the animation group
  31258. */
  31259. restart(): AnimationGroup;
  31260. /**
  31261. * Stop all animations
  31262. * @returns the animation group
  31263. */
  31264. stop(): AnimationGroup;
  31265. /**
  31266. * Set animation weight for all animatables
  31267. * @param weight defines the weight to use
  31268. * @return the animationGroup
  31269. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31270. */
  31271. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31272. /**
  31273. * Synchronize and normalize all animatables with a source animatable
  31274. * @param root defines the root animatable to synchronize with
  31275. * @return the animationGroup
  31276. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31277. */
  31278. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31279. /**
  31280. * Goes to a specific frame in this animation group
  31281. * @param frame the frame number to go to
  31282. * @return the animationGroup
  31283. */
  31284. goToFrame(frame: number): AnimationGroup;
  31285. /**
  31286. * Dispose all associated resources
  31287. */
  31288. dispose(): void;
  31289. private _checkAnimationGroupEnded;
  31290. /**
  31291. * Clone the current animation group and returns a copy
  31292. * @param newName defines the name of the new group
  31293. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31294. * @returns the new aniamtion group
  31295. */
  31296. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31297. /**
  31298. * Returns a new AnimationGroup object parsed from the source provided.
  31299. * @param parsedAnimationGroup defines the source
  31300. * @param scene defines the scene that will receive the animationGroup
  31301. * @returns a new AnimationGroup
  31302. */
  31303. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31304. /**
  31305. * Returns the string "AnimationGroup"
  31306. * @returns "AnimationGroup"
  31307. */
  31308. getClassName(): string;
  31309. /**
  31310. * Creates a detailled string about the object
  31311. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31312. * @returns a string representing the object
  31313. */
  31314. toString(fullDetails?: boolean): string;
  31315. }
  31316. }
  31317. declare module BABYLON {
  31318. /**
  31319. * Define an interface for all classes that will hold resources
  31320. */
  31321. export interface IDisposable {
  31322. /**
  31323. * Releases all held resources
  31324. */
  31325. dispose(): void;
  31326. }
  31327. /** Interface defining initialization parameters for Scene class */
  31328. export interface SceneOptions {
  31329. /**
  31330. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31331. * It will improve performance when the number of geometries becomes important.
  31332. */
  31333. useGeometryUniqueIdsMap?: boolean;
  31334. /**
  31335. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31336. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31337. */
  31338. useMaterialMeshMap?: boolean;
  31339. /**
  31340. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31341. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31342. */
  31343. useClonedMeshhMap?: boolean;
  31344. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31345. virtual?: boolean;
  31346. }
  31347. /**
  31348. * Represents a scene to be rendered by the engine.
  31349. * @see http://doc.babylonjs.com/features/scene
  31350. */
  31351. export class Scene extends AbstractScene implements IAnimatable {
  31352. private static _uniqueIdCounter;
  31353. /** The fog is deactivated */
  31354. static readonly FOGMODE_NONE: number;
  31355. /** The fog density is following an exponential function */
  31356. static readonly FOGMODE_EXP: number;
  31357. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31358. static readonly FOGMODE_EXP2: number;
  31359. /** The fog density is following a linear function. */
  31360. static readonly FOGMODE_LINEAR: number;
  31361. /**
  31362. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31364. */
  31365. static MinDeltaTime: number;
  31366. /**
  31367. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31369. */
  31370. static MaxDeltaTime: number;
  31371. /**
  31372. * Factory used to create the default material.
  31373. * @param name The name of the material to create
  31374. * @param scene The scene to create the material for
  31375. * @returns The default material
  31376. */
  31377. static DefaultMaterialFactory(scene: Scene): Material;
  31378. /**
  31379. * Factory used to create the a collision coordinator.
  31380. * @returns The collision coordinator
  31381. */
  31382. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31383. /** @hidden */ private _inputManager: InputManager;
  31384. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31385. cameraToUseForPointers: Nullable<Camera>;
  31386. /** @hidden */ protected readonly _isScene: boolean;
  31387. /**
  31388. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31389. */
  31390. autoClear: boolean;
  31391. /**
  31392. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31393. */
  31394. autoClearDepthAndStencil: boolean;
  31395. /**
  31396. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31397. */
  31398. clearColor: Color4;
  31399. /**
  31400. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31401. */
  31402. ambientColor: Color3;
  31403. /**
  31404. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31405. * It should only be one of the following (if not the default embedded one):
  31406. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31407. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31408. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31409. * The material properties need to be setup according to the type of texture in use.
  31410. */
  31411. environmentBRDFTexture: BaseTexture;
  31412. /** @hidden */
  31413. protected _environmentTexture: Nullable<BaseTexture>;
  31414. /**
  31415. * Texture used in all pbr material as the reflection texture.
  31416. * As in the majority of the scene they are the same (exception for multi room and so on),
  31417. * this is easier to reference from here than from all the materials.
  31418. */
  31419. /**
  31420. * Texture used in all pbr material as the reflection texture.
  31421. * As in the majority of the scene they are the same (exception for multi room and so on),
  31422. * this is easier to set here than in all the materials.
  31423. */
  31424. environmentTexture: Nullable<BaseTexture>;
  31425. /** @hidden */
  31426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31427. /**
  31428. * Default image processing configuration used either in the rendering
  31429. * Forward main pass or through the imageProcessingPostProcess if present.
  31430. * As in the majority of the scene they are the same (exception for multi camera),
  31431. * this is easier to reference from here than from all the materials and post process.
  31432. *
  31433. * No setter as we it is a shared configuration, you can set the values instead.
  31434. */
  31435. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31436. private _forceWireframe;
  31437. /**
  31438. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31439. */
  31440. forceWireframe: boolean;
  31441. private _forcePointsCloud;
  31442. /**
  31443. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31444. */
  31445. forcePointsCloud: boolean;
  31446. /**
  31447. * Gets or sets the active clipplane 1
  31448. */
  31449. clipPlane: Nullable<Plane>;
  31450. /**
  31451. * Gets or sets the active clipplane 2
  31452. */
  31453. clipPlane2: Nullable<Plane>;
  31454. /**
  31455. * Gets or sets the active clipplane 3
  31456. */
  31457. clipPlane3: Nullable<Plane>;
  31458. /**
  31459. * Gets or sets the active clipplane 4
  31460. */
  31461. clipPlane4: Nullable<Plane>;
  31462. /**
  31463. * Gets or sets a boolean indicating if animations are enabled
  31464. */
  31465. animationsEnabled: boolean;
  31466. private _animationPropertiesOverride;
  31467. /**
  31468. * Gets or sets the animation properties override
  31469. */
  31470. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31471. /**
  31472. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31473. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31474. */
  31475. useConstantAnimationDeltaTime: boolean;
  31476. /**
  31477. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31478. * Please note that it requires to run a ray cast through the scene on every frame
  31479. */
  31480. constantlyUpdateMeshUnderPointer: boolean;
  31481. /**
  31482. * Defines the HTML cursor to use when hovering over interactive elements
  31483. */
  31484. hoverCursor: string;
  31485. /**
  31486. * Defines the HTML default cursor to use (empty by default)
  31487. */
  31488. defaultCursor: string;
  31489. /**
  31490. * This is used to call preventDefault() on pointer down
  31491. * in order to block unwanted artifacts like system double clicks
  31492. */
  31493. preventDefaultOnPointerDown: boolean;
  31494. /**
  31495. * This is used to call preventDefault() on pointer up
  31496. * in order to block unwanted artifacts like system double clicks
  31497. */
  31498. preventDefaultOnPointerUp: boolean;
  31499. /**
  31500. * Gets or sets user defined metadata
  31501. */
  31502. metadata: any;
  31503. /**
  31504. * For internal use only. Please do not use.
  31505. */
  31506. reservedDataStore: any;
  31507. /**
  31508. * Gets the name of the plugin used to load this scene (null by default)
  31509. */
  31510. loadingPluginName: string;
  31511. /**
  31512. * Use this array to add regular expressions used to disable offline support for specific urls
  31513. */
  31514. disableOfflineSupportExceptionRules: RegExp[];
  31515. /**
  31516. * An event triggered when the scene is disposed.
  31517. */
  31518. onDisposeObservable: Observable<Scene>;
  31519. private _onDisposeObserver;
  31520. /** Sets a function to be executed when this scene is disposed. */
  31521. onDispose: () => void;
  31522. /**
  31523. * An event triggered before rendering the scene (right after animations and physics)
  31524. */
  31525. onBeforeRenderObservable: Observable<Scene>;
  31526. private _onBeforeRenderObserver;
  31527. /** Sets a function to be executed before rendering this scene */
  31528. beforeRender: Nullable<() => void>;
  31529. /**
  31530. * An event triggered after rendering the scene
  31531. */
  31532. onAfterRenderObservable: Observable<Scene>;
  31533. private _onAfterRenderObserver;
  31534. /** Sets a function to be executed after rendering this scene */
  31535. afterRender: Nullable<() => void>;
  31536. /**
  31537. * An event triggered before animating the scene
  31538. */
  31539. onBeforeAnimationsObservable: Observable<Scene>;
  31540. /**
  31541. * An event triggered after animations processing
  31542. */
  31543. onAfterAnimationsObservable: Observable<Scene>;
  31544. /**
  31545. * An event triggered before draw calls are ready to be sent
  31546. */
  31547. onBeforeDrawPhaseObservable: Observable<Scene>;
  31548. /**
  31549. * An event triggered after draw calls have been sent
  31550. */
  31551. onAfterDrawPhaseObservable: Observable<Scene>;
  31552. /**
  31553. * An event triggered when the scene is ready
  31554. */
  31555. onReadyObservable: Observable<Scene>;
  31556. /**
  31557. * An event triggered before rendering a camera
  31558. */
  31559. onBeforeCameraRenderObservable: Observable<Camera>;
  31560. private _onBeforeCameraRenderObserver;
  31561. /** Sets a function to be executed before rendering a camera*/
  31562. beforeCameraRender: () => void;
  31563. /**
  31564. * An event triggered after rendering a camera
  31565. */
  31566. onAfterCameraRenderObservable: Observable<Camera>;
  31567. private _onAfterCameraRenderObserver;
  31568. /** Sets a function to be executed after rendering a camera*/
  31569. afterCameraRender: () => void;
  31570. /**
  31571. * An event triggered when active meshes evaluation is about to start
  31572. */
  31573. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31574. /**
  31575. * An event triggered when active meshes evaluation is done
  31576. */
  31577. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31578. /**
  31579. * An event triggered when particles rendering is about to start
  31580. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31581. */
  31582. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31583. /**
  31584. * An event triggered when particles rendering is done
  31585. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31586. */
  31587. onAfterParticlesRenderingObservable: Observable<Scene>;
  31588. /**
  31589. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31590. */
  31591. onDataLoadedObservable: Observable<Scene>;
  31592. /**
  31593. * An event triggered when a camera is created
  31594. */
  31595. onNewCameraAddedObservable: Observable<Camera>;
  31596. /**
  31597. * An event triggered when a camera is removed
  31598. */
  31599. onCameraRemovedObservable: Observable<Camera>;
  31600. /**
  31601. * An event triggered when a light is created
  31602. */
  31603. onNewLightAddedObservable: Observable<Light>;
  31604. /**
  31605. * An event triggered when a light is removed
  31606. */
  31607. onLightRemovedObservable: Observable<Light>;
  31608. /**
  31609. * An event triggered when a geometry is created
  31610. */
  31611. onNewGeometryAddedObservable: Observable<Geometry>;
  31612. /**
  31613. * An event triggered when a geometry is removed
  31614. */
  31615. onGeometryRemovedObservable: Observable<Geometry>;
  31616. /**
  31617. * An event triggered when a transform node is created
  31618. */
  31619. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31620. /**
  31621. * An event triggered when a transform node is removed
  31622. */
  31623. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31624. /**
  31625. * An event triggered when a mesh is created
  31626. */
  31627. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31628. /**
  31629. * An event triggered when a mesh is removed
  31630. */
  31631. onMeshRemovedObservable: Observable<AbstractMesh>;
  31632. /**
  31633. * An event triggered when a skeleton is created
  31634. */
  31635. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31636. /**
  31637. * An event triggered when a skeleton is removed
  31638. */
  31639. onSkeletonRemovedObservable: Observable<Skeleton>;
  31640. /**
  31641. * An event triggered when a material is created
  31642. */
  31643. onNewMaterialAddedObservable: Observable<Material>;
  31644. /**
  31645. * An event triggered when a material is removed
  31646. */
  31647. onMaterialRemovedObservable: Observable<Material>;
  31648. /**
  31649. * An event triggered when a texture is created
  31650. */
  31651. onNewTextureAddedObservable: Observable<BaseTexture>;
  31652. /**
  31653. * An event triggered when a texture is removed
  31654. */
  31655. onTextureRemovedObservable: Observable<BaseTexture>;
  31656. /**
  31657. * An event triggered when render targets are about to be rendered
  31658. * Can happen multiple times per frame.
  31659. */
  31660. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31661. /**
  31662. * An event triggered when render targets were rendered.
  31663. * Can happen multiple times per frame.
  31664. */
  31665. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31666. /**
  31667. * An event triggered before calculating deterministic simulation step
  31668. */
  31669. onBeforeStepObservable: Observable<Scene>;
  31670. /**
  31671. * An event triggered after calculating deterministic simulation step
  31672. */
  31673. onAfterStepObservable: Observable<Scene>;
  31674. /**
  31675. * An event triggered when the activeCamera property is updated
  31676. */
  31677. onActiveCameraChanged: Observable<Scene>;
  31678. /**
  31679. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31680. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31681. * 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)
  31682. */
  31683. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31684. /**
  31685. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31686. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31687. * 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)
  31688. */
  31689. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31690. /**
  31691. * This Observable will when a mesh has been imported into the scene.
  31692. */
  31693. onMeshImportedObservable: Observable<AbstractMesh>;
  31694. /**
  31695. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31696. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31697. */
  31698. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31699. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31700. /**
  31701. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31702. */
  31703. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31704. /**
  31705. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31706. */
  31707. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31708. /**
  31709. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31710. */
  31711. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31712. /** Callback called when a pointer move is detected */
  31713. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31714. /** Callback called when a pointer down is detected */
  31715. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31716. /** Callback called when a pointer up is detected */
  31717. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31718. /** Callback called when a pointer pick is detected */
  31719. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31720. /**
  31721. * 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).
  31722. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31723. */
  31724. onPrePointerObservable: Observable<PointerInfoPre>;
  31725. /**
  31726. * Observable event triggered each time an input event is received from the rendering canvas
  31727. */
  31728. onPointerObservable: Observable<PointerInfo>;
  31729. /**
  31730. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31731. */
  31732. readonly unTranslatedPointer: Vector2;
  31733. /**
  31734. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31735. */
  31736. static DragMovementThreshold: number;
  31737. /**
  31738. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31739. */
  31740. static LongPressDelay: number;
  31741. /**
  31742. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31743. */
  31744. static DoubleClickDelay: number;
  31745. /** If you need to check double click without raising a single click at first click, enable this flag */
  31746. static ExclusiveDoubleClickMode: boolean;
  31747. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  31748. /**
  31749. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31750. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31751. */
  31752. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31753. /**
  31754. * Observable event triggered each time an keyboard event is received from the hosting window
  31755. */
  31756. onKeyboardObservable: Observable<KeyboardInfo>;
  31757. private _useRightHandedSystem;
  31758. /**
  31759. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31760. */
  31761. useRightHandedSystem: boolean;
  31762. private _timeAccumulator;
  31763. private _currentStepId;
  31764. private _currentInternalStep;
  31765. /**
  31766. * Sets the step Id used by deterministic lock step
  31767. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31768. * @param newStepId defines the step Id
  31769. */
  31770. setStepId(newStepId: number): void;
  31771. /**
  31772. * Gets the step Id used by deterministic lock step
  31773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31774. * @returns the step Id
  31775. */
  31776. getStepId(): number;
  31777. /**
  31778. * Gets the internal step used by deterministic lock step
  31779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31780. * @returns the internal step
  31781. */
  31782. getInternalStep(): number;
  31783. private _fogEnabled;
  31784. /**
  31785. * Gets or sets a boolean indicating if fog is enabled on this scene
  31786. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31787. * (Default is true)
  31788. */
  31789. fogEnabled: boolean;
  31790. private _fogMode;
  31791. /**
  31792. * Gets or sets the fog mode to use
  31793. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31794. * | mode | value |
  31795. * | --- | --- |
  31796. * | FOGMODE_NONE | 0 |
  31797. * | FOGMODE_EXP | 1 |
  31798. * | FOGMODE_EXP2 | 2 |
  31799. * | FOGMODE_LINEAR | 3 |
  31800. */
  31801. fogMode: number;
  31802. /**
  31803. * Gets or sets the fog color to use
  31804. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31805. * (Default is Color3(0.2, 0.2, 0.3))
  31806. */
  31807. fogColor: Color3;
  31808. /**
  31809. * Gets or sets the fog density to use
  31810. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31811. * (Default is 0.1)
  31812. */
  31813. fogDensity: number;
  31814. /**
  31815. * Gets or sets the fog start distance to use
  31816. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31817. * (Default is 0)
  31818. */
  31819. fogStart: number;
  31820. /**
  31821. * Gets or sets the fog end distance to use
  31822. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31823. * (Default is 1000)
  31824. */
  31825. fogEnd: number;
  31826. private _shadowsEnabled;
  31827. /**
  31828. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31829. */
  31830. shadowsEnabled: boolean;
  31831. private _lightsEnabled;
  31832. /**
  31833. * Gets or sets a boolean indicating if lights are enabled on this scene
  31834. */
  31835. lightsEnabled: boolean;
  31836. /** All of the active cameras added to this scene. */
  31837. activeCameras: Camera[];
  31838. /** @hidden */ private _activeCamera: Nullable<Camera>;
  31839. /** Gets or sets the current active camera */
  31840. activeCamera: Nullable<Camera>;
  31841. private _defaultMaterial;
  31842. /** The default material used on meshes when no material is affected */
  31843. /** The default material used on meshes when no material is affected */
  31844. defaultMaterial: Material;
  31845. private _texturesEnabled;
  31846. /**
  31847. * Gets or sets a boolean indicating if textures are enabled on this scene
  31848. */
  31849. texturesEnabled: boolean;
  31850. /**
  31851. * Gets or sets a boolean indicating if particles are enabled on this scene
  31852. */
  31853. particlesEnabled: boolean;
  31854. /**
  31855. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31856. */
  31857. spritesEnabled: boolean;
  31858. private _skeletonsEnabled;
  31859. /**
  31860. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31861. */
  31862. skeletonsEnabled: boolean;
  31863. /**
  31864. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31865. */
  31866. lensFlaresEnabled: boolean;
  31867. /**
  31868. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31869. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31870. */
  31871. collisionsEnabled: boolean;
  31872. private _collisionCoordinator;
  31873. /** @hidden */
  31874. readonly collisionCoordinator: ICollisionCoordinator;
  31875. /**
  31876. * Defines the gravity applied to this scene (used only for collisions)
  31877. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31878. */
  31879. gravity: Vector3;
  31880. /**
  31881. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31882. */
  31883. postProcessesEnabled: boolean;
  31884. /**
  31885. * The list of postprocesses added to the scene
  31886. */
  31887. postProcesses: PostProcess[];
  31888. /**
  31889. * Gets the current postprocess manager
  31890. */
  31891. postProcessManager: PostProcessManager;
  31892. /**
  31893. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31894. */
  31895. renderTargetsEnabled: boolean;
  31896. /**
  31897. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31898. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31899. */
  31900. dumpNextRenderTargets: boolean;
  31901. /**
  31902. * The list of user defined render targets added to the scene
  31903. */
  31904. customRenderTargets: RenderTargetTexture[];
  31905. /**
  31906. * Defines if texture loading must be delayed
  31907. * If true, textures will only be loaded when they need to be rendered
  31908. */
  31909. useDelayedTextureLoading: boolean;
  31910. /**
  31911. * Gets the list of meshes imported to the scene through SceneLoader
  31912. */
  31913. importedMeshesFiles: String[];
  31914. /**
  31915. * Gets or sets a boolean indicating if probes are enabled on this scene
  31916. */
  31917. probesEnabled: boolean;
  31918. /**
  31919. * Gets or sets the current offline provider to use to store scene data
  31920. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31921. */
  31922. offlineProvider: IOfflineProvider;
  31923. /**
  31924. * Gets or sets the action manager associated with the scene
  31925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31926. */
  31927. actionManager: AbstractActionManager;
  31928. private _meshesForIntersections;
  31929. /**
  31930. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31931. */
  31932. proceduralTexturesEnabled: boolean;
  31933. private _engine;
  31934. private _totalVertices;
  31935. /** @hidden */ private _activeIndices: PerfCounter;
  31936. /** @hidden */ private _activeParticles: PerfCounter;
  31937. /** @hidden */ private _activeBones: PerfCounter;
  31938. private _animationRatio;
  31939. /** @hidden */ private _animationTimeLast: number;
  31940. /** @hidden */ private _animationTime: number;
  31941. /**
  31942. * Gets or sets a general scale for animation speed
  31943. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31944. */
  31945. animationTimeScale: number;
  31946. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  31947. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  31948. /** @hidden */ private _cachedVisibility: Nullable<number>;
  31949. private _renderId;
  31950. private _frameId;
  31951. private _executeWhenReadyTimeoutId;
  31952. private _intermediateRendering;
  31953. private _viewUpdateFlag;
  31954. private _projectionUpdateFlag;
  31955. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  31956. private _activeRequests;
  31957. /** @hidden */ private _pendingData: any[];
  31958. private _isDisposed;
  31959. /**
  31960. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31961. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31962. */
  31963. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31964. private _activeMeshes;
  31965. private _processedMaterials;
  31966. private _renderTargets;
  31967. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  31968. private _activeSkeletons;
  31969. private _softwareSkinnedMeshes;
  31970. private _renderingManager;
  31971. /** @hidden */ private _activeAnimatables: Animatable[];
  31972. private _transformMatrix;
  31973. private _sceneUbo;
  31974. /** @hidden */ private _viewMatrix: Matrix;
  31975. private _projectionMatrix;
  31976. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  31977. /** @hidden */ private _frustumPlanes: Plane[];
  31978. /**
  31979. * Gets the list of frustum planes (built from the active camera)
  31980. */
  31981. readonly frustumPlanes: Plane[];
  31982. /**
  31983. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31984. * This is useful if there are more lights that the maximum simulteanous authorized
  31985. */
  31986. requireLightSorting: boolean;
  31987. /** @hidden */
  31988. readonly useMaterialMeshMap: boolean;
  31989. /** @hidden */
  31990. readonly useClonedMeshhMap: boolean;
  31991. private _externalData;
  31992. private _uid;
  31993. /**
  31994. * @hidden
  31995. * Backing store of defined scene components.
  31996. */ private _components: ISceneComponent[];
  31997. /**
  31998. * @hidden
  31999. * Backing store of defined scene components.
  32000. */ private _serializableComponents: ISceneSerializableComponent[];
  32001. /**
  32002. * List of components to register on the next registration step.
  32003. */
  32004. private _transientComponents;
  32005. /**
  32006. * Registers the transient components if needed.
  32007. */
  32008. private _registerTransientComponents;
  32009. /**
  32010. * @hidden
  32011. * Add a component to the scene.
  32012. * Note that the ccomponent could be registered on th next frame if this is called after
  32013. * the register component stage.
  32014. * @param component Defines the component to add to the scene
  32015. */ private _addComponent(component: ISceneComponent): void;
  32016. /**
  32017. * @hidden
  32018. * Gets a component from the scene.
  32019. * @param name defines the name of the component to retrieve
  32020. * @returns the component or null if not present
  32021. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32022. /**
  32023. * @hidden
  32024. * Defines the actions happening before camera updates.
  32025. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32026. /**
  32027. * @hidden
  32028. * Defines the actions happening before clear the canvas.
  32029. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32030. /**
  32031. * @hidden
  32032. * Defines the actions when collecting render targets for the frame.
  32033. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32034. /**
  32035. * @hidden
  32036. * Defines the actions happening for one camera in the frame.
  32037. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32038. /**
  32039. * @hidden
  32040. * Defines the actions happening during the per mesh ready checks.
  32041. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32042. /**
  32043. * @hidden
  32044. * Defines the actions happening before evaluate active mesh checks.
  32045. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32046. /**
  32047. * @hidden
  32048. * Defines the actions happening during the evaluate sub mesh checks.
  32049. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32050. /**
  32051. * @hidden
  32052. * Defines the actions happening during the active mesh stage.
  32053. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32054. /**
  32055. * @hidden
  32056. * Defines the actions happening during the per camera render target step.
  32057. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32058. /**
  32059. * @hidden
  32060. * Defines the actions happening just before the active camera is drawing.
  32061. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32062. /**
  32063. * @hidden
  32064. * Defines the actions happening just before a render target is drawing.
  32065. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32066. /**
  32067. * @hidden
  32068. * Defines the actions happening just before a rendering group is drawing.
  32069. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32070. /**
  32071. * @hidden
  32072. * Defines the actions happening just before a mesh is drawing.
  32073. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32074. /**
  32075. * @hidden
  32076. * Defines the actions happening just after a mesh has been drawn.
  32077. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32078. /**
  32079. * @hidden
  32080. * Defines the actions happening just after a rendering group has been drawn.
  32081. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32082. /**
  32083. * @hidden
  32084. * Defines the actions happening just after the active camera has been drawn.
  32085. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32086. /**
  32087. * @hidden
  32088. * Defines the actions happening just after a render target has been drawn.
  32089. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32090. /**
  32091. * @hidden
  32092. * Defines the actions happening just after rendering all cameras and computing intersections.
  32093. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32094. /**
  32095. * @hidden
  32096. * Defines the actions happening when a pointer move event happens.
  32097. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32098. /**
  32099. * @hidden
  32100. * Defines the actions happening when a pointer down event happens.
  32101. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32102. /**
  32103. * @hidden
  32104. * Defines the actions happening when a pointer up event happens.
  32105. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32106. /**
  32107. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32108. */
  32109. private geometriesByUniqueId;
  32110. /**
  32111. * Creates a new Scene
  32112. * @param engine defines the engine to use to render this scene
  32113. * @param options defines the scene options
  32114. */
  32115. constructor(engine: Engine, options?: SceneOptions);
  32116. /**
  32117. * Gets a string idenfifying the name of the class
  32118. * @returns "Scene" string
  32119. */
  32120. getClassName(): string;
  32121. private _defaultMeshCandidates;
  32122. /**
  32123. * @hidden
  32124. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32125. private _defaultSubMeshCandidates;
  32126. /**
  32127. * @hidden
  32128. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32129. /**
  32130. * Sets the default candidate providers for the scene.
  32131. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32132. * and getCollidingSubMeshCandidates to their default function
  32133. */
  32134. setDefaultCandidateProviders(): void;
  32135. /**
  32136. * Gets the mesh that is currently under the pointer
  32137. */
  32138. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32139. /**
  32140. * Gets or sets the current on-screen X position of the pointer
  32141. */
  32142. pointerX: number;
  32143. /**
  32144. * Gets or sets the current on-screen Y position of the pointer
  32145. */
  32146. pointerY: number;
  32147. /**
  32148. * Gets the cached material (ie. the latest rendered one)
  32149. * @returns the cached material
  32150. */
  32151. getCachedMaterial(): Nullable<Material>;
  32152. /**
  32153. * Gets the cached effect (ie. the latest rendered one)
  32154. * @returns the cached effect
  32155. */
  32156. getCachedEffect(): Nullable<Effect>;
  32157. /**
  32158. * Gets the cached visibility state (ie. the latest rendered one)
  32159. * @returns the cached visibility state
  32160. */
  32161. getCachedVisibility(): Nullable<number>;
  32162. /**
  32163. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32164. * @param material defines the current material
  32165. * @param effect defines the current effect
  32166. * @param visibility defines the current visibility state
  32167. * @returns true if one parameter is not cached
  32168. */
  32169. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32170. /**
  32171. * Gets the engine associated with the scene
  32172. * @returns an Engine
  32173. */
  32174. getEngine(): Engine;
  32175. /**
  32176. * Gets the total number of vertices rendered per frame
  32177. * @returns the total number of vertices rendered per frame
  32178. */
  32179. getTotalVertices(): number;
  32180. /**
  32181. * Gets the performance counter for total vertices
  32182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32183. */
  32184. readonly totalVerticesPerfCounter: PerfCounter;
  32185. /**
  32186. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32187. * @returns the total number of active indices rendered per frame
  32188. */
  32189. getActiveIndices(): number;
  32190. /**
  32191. * Gets the performance counter for active indices
  32192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32193. */
  32194. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32195. /**
  32196. * Gets the total number of active particles rendered per frame
  32197. * @returns the total number of active particles rendered per frame
  32198. */
  32199. getActiveParticles(): number;
  32200. /**
  32201. * Gets the performance counter for active particles
  32202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32203. */
  32204. readonly activeParticlesPerfCounter: PerfCounter;
  32205. /**
  32206. * Gets the total number of active bones rendered per frame
  32207. * @returns the total number of active bones rendered per frame
  32208. */
  32209. getActiveBones(): number;
  32210. /**
  32211. * Gets the performance counter for active bones
  32212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32213. */
  32214. readonly activeBonesPerfCounter: PerfCounter;
  32215. /**
  32216. * Gets the array of active meshes
  32217. * @returns an array of AbstractMesh
  32218. */
  32219. getActiveMeshes(): SmartArray<AbstractMesh>;
  32220. /**
  32221. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32222. * @returns a number
  32223. */
  32224. getAnimationRatio(): number;
  32225. /**
  32226. * Gets an unique Id for the current render phase
  32227. * @returns a number
  32228. */
  32229. getRenderId(): number;
  32230. /**
  32231. * Gets an unique Id for the current frame
  32232. * @returns a number
  32233. */
  32234. getFrameId(): number;
  32235. /** Call this function if you want to manually increment the render Id*/
  32236. incrementRenderId(): void;
  32237. private _createUbo;
  32238. /**
  32239. * Use this method to simulate a pointer move on a mesh
  32240. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32241. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32242. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32243. * @returns the current scene
  32244. */
  32245. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32246. /**
  32247. * Use this method to simulate a pointer down on a mesh
  32248. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32249. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32250. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32251. * @returns the current scene
  32252. */
  32253. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32254. /**
  32255. * Use this method to simulate a pointer up on a mesh
  32256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32259. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32260. * @returns the current scene
  32261. */
  32262. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32263. /**
  32264. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32265. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32266. * @returns true if the pointer was captured
  32267. */
  32268. isPointerCaptured(pointerId?: number): boolean;
  32269. /**
  32270. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32271. * @param attachUp defines if you want to attach events to pointerup
  32272. * @param attachDown defines if you want to attach events to pointerdown
  32273. * @param attachMove defines if you want to attach events to pointermove
  32274. */
  32275. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32276. /** Detaches all event handlers*/
  32277. detachControl(): void;
  32278. /**
  32279. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32280. * Delay loaded resources are not taking in account
  32281. * @return true if all required resources are ready
  32282. */
  32283. isReady(): boolean;
  32284. /** Resets all cached information relative to material (including effect and visibility) */
  32285. resetCachedMaterial(): void;
  32286. /**
  32287. * Registers a function to be called before every frame render
  32288. * @param func defines the function to register
  32289. */
  32290. registerBeforeRender(func: () => void): void;
  32291. /**
  32292. * Unregisters a function called before every frame render
  32293. * @param func defines the function to unregister
  32294. */
  32295. unregisterBeforeRender(func: () => void): void;
  32296. /**
  32297. * Registers a function to be called after every frame render
  32298. * @param func defines the function to register
  32299. */
  32300. registerAfterRender(func: () => void): void;
  32301. /**
  32302. * Unregisters a function called after every frame render
  32303. * @param func defines the function to unregister
  32304. */
  32305. unregisterAfterRender(func: () => void): void;
  32306. private _executeOnceBeforeRender;
  32307. /**
  32308. * The provided function will run before render once and will be disposed afterwards.
  32309. * A timeout delay can be provided so that the function will be executed in N ms.
  32310. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32311. * @param func The function to be executed.
  32312. * @param timeout optional delay in ms
  32313. */
  32314. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32315. /** @hidden */ private _addPendingData(data: any): void;
  32316. /** @hidden */ private _removePendingData(data: any): void;
  32317. /**
  32318. * Returns the number of items waiting to be loaded
  32319. * @returns the number of items waiting to be loaded
  32320. */
  32321. getWaitingItemsCount(): number;
  32322. /**
  32323. * Returns a boolean indicating if the scene is still loading data
  32324. */
  32325. readonly isLoading: boolean;
  32326. /**
  32327. * Registers a function to be executed when the scene is ready
  32328. * @param {Function} func - the function to be executed
  32329. */
  32330. executeWhenReady(func: () => void): void;
  32331. /**
  32332. * Returns a promise that resolves when the scene is ready
  32333. * @returns A promise that resolves when the scene is ready
  32334. */
  32335. whenReadyAsync(): Promise<void>;
  32336. /** @hidden */ private _checkIsReady(): void;
  32337. /**
  32338. * Gets all animatable attached to the scene
  32339. */
  32340. readonly animatables: Animatable[];
  32341. /**
  32342. * Resets the last animation time frame.
  32343. * Useful to override when animations start running when loading a scene for the first time.
  32344. */
  32345. resetLastAnimationTimeFrame(): void;
  32346. /**
  32347. * Gets the current view matrix
  32348. * @returns a Matrix
  32349. */
  32350. getViewMatrix(): Matrix;
  32351. /**
  32352. * Gets the current projection matrix
  32353. * @returns a Matrix
  32354. */
  32355. getProjectionMatrix(): Matrix;
  32356. /**
  32357. * Gets the current transform matrix
  32358. * @returns a Matrix made of View * Projection
  32359. */
  32360. getTransformMatrix(): Matrix;
  32361. /**
  32362. * Sets the current transform matrix
  32363. * @param viewL defines the View matrix to use
  32364. * @param projectionL defines the Projection matrix to use
  32365. * @param viewR defines the right View matrix to use (if provided)
  32366. * @param projectionR defines the right Projection matrix to use (if provided)
  32367. */
  32368. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32369. /**
  32370. * Gets the uniform buffer used to store scene data
  32371. * @returns a UniformBuffer
  32372. */
  32373. getSceneUniformBuffer(): UniformBuffer;
  32374. /**
  32375. * Gets an unique (relatively to the current scene) Id
  32376. * @returns an unique number for the scene
  32377. */
  32378. getUniqueId(): number;
  32379. /**
  32380. * Add a mesh to the list of scene's meshes
  32381. * @param newMesh defines the mesh to add
  32382. * @param recursive if all child meshes should also be added to the scene
  32383. */
  32384. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32385. /**
  32386. * Remove a mesh for the list of scene's meshes
  32387. * @param toRemove defines the mesh to remove
  32388. * @param recursive if all child meshes should also be removed from the scene
  32389. * @returns the index where the mesh was in the mesh list
  32390. */
  32391. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32392. /**
  32393. * Add a transform node to the list of scene's transform nodes
  32394. * @param newTransformNode defines the transform node to add
  32395. */
  32396. addTransformNode(newTransformNode: TransformNode): void;
  32397. /**
  32398. * Remove a transform node for the list of scene's transform nodes
  32399. * @param toRemove defines the transform node to remove
  32400. * @returns the index where the transform node was in the transform node list
  32401. */
  32402. removeTransformNode(toRemove: TransformNode): number;
  32403. /**
  32404. * Remove a skeleton for the list of scene's skeletons
  32405. * @param toRemove defines the skeleton to remove
  32406. * @returns the index where the skeleton was in the skeleton list
  32407. */
  32408. removeSkeleton(toRemove: Skeleton): number;
  32409. /**
  32410. * Remove a morph target for the list of scene's morph targets
  32411. * @param toRemove defines the morph target to remove
  32412. * @returns the index where the morph target was in the morph target list
  32413. */
  32414. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32415. /**
  32416. * Remove a light for the list of scene's lights
  32417. * @param toRemove defines the light to remove
  32418. * @returns the index where the light was in the light list
  32419. */
  32420. removeLight(toRemove: Light): number;
  32421. /**
  32422. * Remove a camera for the list of scene's cameras
  32423. * @param toRemove defines the camera to remove
  32424. * @returns the index where the camera was in the camera list
  32425. */
  32426. removeCamera(toRemove: Camera): number;
  32427. /**
  32428. * Remove a particle system for the list of scene's particle systems
  32429. * @param toRemove defines the particle system to remove
  32430. * @returns the index where the particle system was in the particle system list
  32431. */
  32432. removeParticleSystem(toRemove: IParticleSystem): number;
  32433. /**
  32434. * Remove a animation for the list of scene's animations
  32435. * @param toRemove defines the animation to remove
  32436. * @returns the index where the animation was in the animation list
  32437. */
  32438. removeAnimation(toRemove: Animation): number;
  32439. /**
  32440. * Will stop the animation of the given target
  32441. * @param target - the target
  32442. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32443. * @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)
  32444. */
  32445. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32446. /**
  32447. * Removes the given animation group from this scene.
  32448. * @param toRemove The animation group to remove
  32449. * @returns The index of the removed animation group
  32450. */
  32451. removeAnimationGroup(toRemove: AnimationGroup): number;
  32452. /**
  32453. * Removes the given multi-material from this scene.
  32454. * @param toRemove The multi-material to remove
  32455. * @returns The index of the removed multi-material
  32456. */
  32457. removeMultiMaterial(toRemove: MultiMaterial): number;
  32458. /**
  32459. * Removes the given material from this scene.
  32460. * @param toRemove The material to remove
  32461. * @returns The index of the removed material
  32462. */
  32463. removeMaterial(toRemove: Material): number;
  32464. /**
  32465. * Removes the given action manager from this scene.
  32466. * @param toRemove The action manager to remove
  32467. * @returns The index of the removed action manager
  32468. */
  32469. removeActionManager(toRemove: AbstractActionManager): number;
  32470. /**
  32471. * Removes the given texture from this scene.
  32472. * @param toRemove The texture to remove
  32473. * @returns The index of the removed texture
  32474. */
  32475. removeTexture(toRemove: BaseTexture): number;
  32476. /**
  32477. * Adds the given light to this scene
  32478. * @param newLight The light to add
  32479. */
  32480. addLight(newLight: Light): void;
  32481. /**
  32482. * Sorts the list list based on light priorities
  32483. */
  32484. sortLightsByPriority(): void;
  32485. /**
  32486. * Adds the given camera to this scene
  32487. * @param newCamera The camera to add
  32488. */
  32489. addCamera(newCamera: Camera): void;
  32490. /**
  32491. * Adds the given skeleton to this scene
  32492. * @param newSkeleton The skeleton to add
  32493. */
  32494. addSkeleton(newSkeleton: Skeleton): void;
  32495. /**
  32496. * Adds the given particle system to this scene
  32497. * @param newParticleSystem The particle system to add
  32498. */
  32499. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32500. /**
  32501. * Adds the given animation to this scene
  32502. * @param newAnimation The animation to add
  32503. */
  32504. addAnimation(newAnimation: Animation): void;
  32505. /**
  32506. * Adds the given animation group to this scene.
  32507. * @param newAnimationGroup The animation group to add
  32508. */
  32509. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32510. /**
  32511. * Adds the given multi-material to this scene
  32512. * @param newMultiMaterial The multi-material to add
  32513. */
  32514. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32515. /**
  32516. * Adds the given material to this scene
  32517. * @param newMaterial The material to add
  32518. */
  32519. addMaterial(newMaterial: Material): void;
  32520. /**
  32521. * Adds the given morph target to this scene
  32522. * @param newMorphTargetManager The morph target to add
  32523. */
  32524. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32525. /**
  32526. * Adds the given geometry to this scene
  32527. * @param newGeometry The geometry to add
  32528. */
  32529. addGeometry(newGeometry: Geometry): void;
  32530. /**
  32531. * Adds the given action manager to this scene
  32532. * @param newActionManager The action manager to add
  32533. */
  32534. addActionManager(newActionManager: AbstractActionManager): void;
  32535. /**
  32536. * Adds the given texture to this scene.
  32537. * @param newTexture The texture to add
  32538. */
  32539. addTexture(newTexture: BaseTexture): void;
  32540. /**
  32541. * Switch active camera
  32542. * @param newCamera defines the new active camera
  32543. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32544. */
  32545. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32546. /**
  32547. * sets the active camera of the scene using its ID
  32548. * @param id defines the camera's ID
  32549. * @return the new active camera or null if none found.
  32550. */
  32551. setActiveCameraByID(id: string): Nullable<Camera>;
  32552. /**
  32553. * sets the active camera of the scene using its name
  32554. * @param name defines the camera's name
  32555. * @returns the new active camera or null if none found.
  32556. */
  32557. setActiveCameraByName(name: string): Nullable<Camera>;
  32558. /**
  32559. * get an animation group using its name
  32560. * @param name defines the material's name
  32561. * @return the animation group or null if none found.
  32562. */
  32563. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32564. /**
  32565. * Get a material using its unique id
  32566. * @param uniqueId defines the material's unique id
  32567. * @return the material or null if none found.
  32568. */
  32569. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32570. /**
  32571. * get a material using its id
  32572. * @param id defines the material's ID
  32573. * @return the material or null if none found.
  32574. */
  32575. getMaterialByID(id: string): Nullable<Material>;
  32576. /**
  32577. * Gets a material using its name
  32578. * @param name defines the material's name
  32579. * @return the material or null if none found.
  32580. */
  32581. getMaterialByName(name: string): Nullable<Material>;
  32582. /**
  32583. * Gets a camera using its id
  32584. * @param id defines the id to look for
  32585. * @returns the camera or null if not found
  32586. */
  32587. getCameraByID(id: string): Nullable<Camera>;
  32588. /**
  32589. * Gets a camera using its unique id
  32590. * @param uniqueId defines the unique id to look for
  32591. * @returns the camera or null if not found
  32592. */
  32593. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32594. /**
  32595. * Gets a camera using its name
  32596. * @param name defines the camera's name
  32597. * @return the camera or null if none found.
  32598. */
  32599. getCameraByName(name: string): Nullable<Camera>;
  32600. /**
  32601. * Gets a bone using its id
  32602. * @param id defines the bone's id
  32603. * @return the bone or null if not found
  32604. */
  32605. getBoneByID(id: string): Nullable<Bone>;
  32606. /**
  32607. * Gets a bone using its id
  32608. * @param name defines the bone's name
  32609. * @return the bone or null if not found
  32610. */
  32611. getBoneByName(name: string): Nullable<Bone>;
  32612. /**
  32613. * Gets a light node using its name
  32614. * @param name defines the the light's name
  32615. * @return the light or null if none found.
  32616. */
  32617. getLightByName(name: string): Nullable<Light>;
  32618. /**
  32619. * Gets a light node using its id
  32620. * @param id defines the light's id
  32621. * @return the light or null if none found.
  32622. */
  32623. getLightByID(id: string): Nullable<Light>;
  32624. /**
  32625. * Gets a light node using its scene-generated unique ID
  32626. * @param uniqueId defines the light's unique id
  32627. * @return the light or null if none found.
  32628. */
  32629. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32630. /**
  32631. * Gets a particle system by id
  32632. * @param id defines the particle system id
  32633. * @return the corresponding system or null if none found
  32634. */
  32635. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32636. /**
  32637. * Gets a geometry using its ID
  32638. * @param id defines the geometry's id
  32639. * @return the geometry or null if none found.
  32640. */
  32641. getGeometryByID(id: string): Nullable<Geometry>;
  32642. private _getGeometryByUniqueID;
  32643. /**
  32644. * Add a new geometry to this scene
  32645. * @param geometry defines the geometry to be added to the scene.
  32646. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32647. * @return a boolean defining if the geometry was added or not
  32648. */
  32649. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32650. /**
  32651. * Removes an existing geometry
  32652. * @param geometry defines the geometry to be removed from the scene
  32653. * @return a boolean defining if the geometry was removed or not
  32654. */
  32655. removeGeometry(geometry: Geometry): boolean;
  32656. /**
  32657. * Gets the list of geometries attached to the scene
  32658. * @returns an array of Geometry
  32659. */
  32660. getGeometries(): Geometry[];
  32661. /**
  32662. * Gets the first added mesh found of a given ID
  32663. * @param id defines the id to search for
  32664. * @return the mesh found or null if not found at all
  32665. */
  32666. getMeshByID(id: string): Nullable<AbstractMesh>;
  32667. /**
  32668. * Gets a list of meshes using their id
  32669. * @param id defines the id to search for
  32670. * @returns a list of meshes
  32671. */
  32672. getMeshesByID(id: string): Array<AbstractMesh>;
  32673. /**
  32674. * Gets the first added transform node found of a given ID
  32675. * @param id defines the id to search for
  32676. * @return the found transform node or null if not found at all.
  32677. */
  32678. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32679. /**
  32680. * Gets a transform node with its auto-generated unique id
  32681. * @param uniqueId efines the unique id to search for
  32682. * @return the found transform node or null if not found at all.
  32683. */
  32684. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32685. /**
  32686. * Gets a list of transform nodes using their id
  32687. * @param id defines the id to search for
  32688. * @returns a list of transform nodes
  32689. */
  32690. getTransformNodesByID(id: string): Array<TransformNode>;
  32691. /**
  32692. * Gets a mesh with its auto-generated unique id
  32693. * @param uniqueId defines the unique id to search for
  32694. * @return the found mesh or null if not found at all.
  32695. */
  32696. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32697. /**
  32698. * Gets a the last added mesh using a given id
  32699. * @param id defines the id to search for
  32700. * @return the found mesh or null if not found at all.
  32701. */
  32702. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32703. /**
  32704. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32705. * @param id defines the id to search for
  32706. * @return the found node or null if not found at all
  32707. */
  32708. getLastEntryByID(id: string): Nullable<Node>;
  32709. /**
  32710. * Gets a node (Mesh, Camera, Light) using a given id
  32711. * @param id defines the id to search for
  32712. * @return the found node or null if not found at all
  32713. */
  32714. getNodeByID(id: string): Nullable<Node>;
  32715. /**
  32716. * Gets a node (Mesh, Camera, Light) using a given name
  32717. * @param name defines the name to search for
  32718. * @return the found node or null if not found at all.
  32719. */
  32720. getNodeByName(name: string): Nullable<Node>;
  32721. /**
  32722. * Gets a mesh using a given name
  32723. * @param name defines the name to search for
  32724. * @return the found mesh or null if not found at all.
  32725. */
  32726. getMeshByName(name: string): Nullable<AbstractMesh>;
  32727. /**
  32728. * Gets a transform node using a given name
  32729. * @param name defines the name to search for
  32730. * @return the found transform node or null if not found at all.
  32731. */
  32732. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32733. /**
  32734. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32735. * @param id defines the id to search for
  32736. * @return the found skeleton or null if not found at all.
  32737. */
  32738. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32739. /**
  32740. * Gets a skeleton using a given auto generated unique id
  32741. * @param uniqueId defines the unique id to search for
  32742. * @return the found skeleton or null if not found at all.
  32743. */
  32744. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32745. /**
  32746. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32747. * @param id defines the id to search for
  32748. * @return the found skeleton or null if not found at all.
  32749. */
  32750. getSkeletonById(id: string): Nullable<Skeleton>;
  32751. /**
  32752. * Gets a skeleton using a given name
  32753. * @param name defines the name to search for
  32754. * @return the found skeleton or null if not found at all.
  32755. */
  32756. getSkeletonByName(name: string): Nullable<Skeleton>;
  32757. /**
  32758. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32759. * @param id defines the id to search for
  32760. * @return the found morph target manager or null if not found at all.
  32761. */
  32762. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32763. /**
  32764. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32765. * @param id defines the id to search for
  32766. * @return the found morph target or null if not found at all.
  32767. */
  32768. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32769. /**
  32770. * Gets a boolean indicating if the given mesh is active
  32771. * @param mesh defines the mesh to look for
  32772. * @returns true if the mesh is in the active list
  32773. */
  32774. isActiveMesh(mesh: AbstractMesh): boolean;
  32775. /**
  32776. * Return a unique id as a string which can serve as an identifier for the scene
  32777. */
  32778. readonly uid: string;
  32779. /**
  32780. * Add an externaly attached data from its key.
  32781. * This method call will fail and return false, if such key already exists.
  32782. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32783. * @param key the unique key that identifies the data
  32784. * @param data the data object to associate to the key for this Engine instance
  32785. * @return true if no such key were already present and the data was added successfully, false otherwise
  32786. */
  32787. addExternalData<T>(key: string, data: T): boolean;
  32788. /**
  32789. * Get an externaly attached data from its key
  32790. * @param key the unique key that identifies the data
  32791. * @return the associated data, if present (can be null), or undefined if not present
  32792. */
  32793. getExternalData<T>(key: string): Nullable<T>;
  32794. /**
  32795. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32796. * @param key the unique key that identifies the data
  32797. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32798. * @return the associated data, can be null if the factory returned null.
  32799. */
  32800. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32801. /**
  32802. * Remove an externaly attached data from the Engine instance
  32803. * @param key the unique key that identifies the data
  32804. * @return true if the data was successfully removed, false if it doesn't exist
  32805. */
  32806. removeExternalData(key: string): boolean;
  32807. private _evaluateSubMesh;
  32808. /**
  32809. * Clear the processed materials smart array preventing retention point in material dispose.
  32810. */
  32811. freeProcessedMaterials(): void;
  32812. private _preventFreeActiveMeshesAndRenderingGroups;
  32813. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32814. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32815. * when disposing several meshes in a row or a hierarchy of meshes.
  32816. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32817. */
  32818. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32819. /**
  32820. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32821. */
  32822. freeActiveMeshes(): void;
  32823. /**
  32824. * Clear the info related to rendering groups preventing retention points during dispose.
  32825. */
  32826. freeRenderingGroups(): void;
  32827. /** @hidden */ private _isInIntermediateRendering(): boolean;
  32828. /**
  32829. * Lambda returning the list of potentially active meshes.
  32830. */
  32831. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32832. /**
  32833. * Lambda returning the list of potentially active sub meshes.
  32834. */
  32835. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32836. /**
  32837. * Lambda returning the list of potentially intersecting sub meshes.
  32838. */
  32839. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32840. /**
  32841. * Lambda returning the list of potentially colliding sub meshes.
  32842. */
  32843. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32844. private _activeMeshesFrozen;
  32845. /**
  32846. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32847. * @returns the current scene
  32848. */
  32849. freezeActiveMeshes(): Scene;
  32850. /**
  32851. * Use this function to restart evaluating active meshes on every frame
  32852. * @returns the current scene
  32853. */
  32854. unfreezeActiveMeshes(): Scene;
  32855. private _evaluateActiveMeshes;
  32856. private _activeMesh;
  32857. /**
  32858. * Update the transform matrix to update from the current active camera
  32859. * @param force defines a boolean used to force the update even if cache is up to date
  32860. */
  32861. updateTransformMatrix(force?: boolean): void;
  32862. private _bindFrameBuffer;
  32863. /** @hidden */ private _allowPostProcessClearColor: boolean;
  32864. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  32865. private _processSubCameras;
  32866. private _checkIntersections;
  32867. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  32868. /**
  32869. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32870. */
  32871. getDeterministicFrameTime: () => number;
  32872. /** @hidden */ private _animate(): void;
  32873. /** Execute all animations (for a frame) */
  32874. animate(): void;
  32875. /**
  32876. * Render the scene
  32877. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32878. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32879. */
  32880. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32881. /**
  32882. * Freeze all materials
  32883. * A frozen material will not be updatable but should be faster to render
  32884. */
  32885. freezeMaterials(): void;
  32886. /**
  32887. * Unfreeze all materials
  32888. * A frozen material will not be updatable but should be faster to render
  32889. */
  32890. unfreezeMaterials(): void;
  32891. /**
  32892. * Releases all held ressources
  32893. */
  32894. dispose(): void;
  32895. /**
  32896. * Gets if the scene is already disposed
  32897. */
  32898. readonly isDisposed: boolean;
  32899. /**
  32900. * Call this function to reduce memory footprint of the scene.
  32901. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32902. */
  32903. clearCachedVertexData(): void;
  32904. /**
  32905. * This function will remove the local cached buffer data from texture.
  32906. * It will save memory but will prevent the texture from being rebuilt
  32907. */
  32908. cleanCachedTextureBuffer(): void;
  32909. /**
  32910. * Get the world extend vectors with an optional filter
  32911. *
  32912. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32913. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32914. */
  32915. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32916. min: Vector3;
  32917. max: Vector3;
  32918. };
  32919. /**
  32920. * Creates a ray that can be used to pick in the scene
  32921. * @param x defines the x coordinate of the origin (on-screen)
  32922. * @param y defines the y coordinate of the origin (on-screen)
  32923. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32924. * @param camera defines the camera to use for the picking
  32925. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32926. * @returns a Ray
  32927. */
  32928. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32929. /**
  32930. * Creates a ray that can be used to pick in the scene
  32931. * @param x defines the x coordinate of the origin (on-screen)
  32932. * @param y defines the y coordinate of the origin (on-screen)
  32933. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32934. * @param result defines the ray where to store the picking ray
  32935. * @param camera defines the camera to use for the picking
  32936. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32937. * @returns the current scene
  32938. */
  32939. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32940. /**
  32941. * Creates a ray that can be used to pick in the scene
  32942. * @param x defines the x coordinate of the origin (on-screen)
  32943. * @param y defines the y coordinate of the origin (on-screen)
  32944. * @param camera defines the camera to use for the picking
  32945. * @returns a Ray
  32946. */
  32947. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32948. /**
  32949. * Creates a ray that can be used to pick in the scene
  32950. * @param x defines the x coordinate of the origin (on-screen)
  32951. * @param y defines the y coordinate of the origin (on-screen)
  32952. * @param result defines the ray where to store the picking ray
  32953. * @param camera defines the camera to use for the picking
  32954. * @returns the current scene
  32955. */
  32956. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32957. /** Launch a ray to try to pick a mesh in the scene
  32958. * @param x position on screen
  32959. * @param y position on screen
  32960. * @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
  32961. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32962. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32963. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32964. * @returns a PickingInfo
  32965. */
  32966. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32967. /** Use the given ray to pick a mesh in the scene
  32968. * @param ray The ray to use to pick meshes
  32969. * @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
  32970. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32971. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32972. * @returns a PickingInfo
  32973. */
  32974. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32975. /**
  32976. * Launch a ray to try to pick a mesh in the scene
  32977. * @param x X position on screen
  32978. * @param y Y position on screen
  32979. * @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
  32980. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32981. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32982. * @returns an array of PickingInfo
  32983. */
  32984. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32985. /**
  32986. * Launch a ray to try to pick a mesh in the scene
  32987. * @param ray Ray to use
  32988. * @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
  32989. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32990. * @returns an array of PickingInfo
  32991. */
  32992. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32993. /**
  32994. * Force the value of meshUnderPointer
  32995. * @param mesh defines the mesh to use
  32996. */
  32997. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32998. /**
  32999. * Gets the mesh under the pointer
  33000. * @returns a Mesh or null if no mesh is under the pointer
  33001. */
  33002. getPointerOverMesh(): Nullable<AbstractMesh>;
  33003. /** @hidden */ private _rebuildGeometries(): void;
  33004. /** @hidden */ private _rebuildTextures(): void;
  33005. private _getByTags;
  33006. /**
  33007. * Get a list of meshes by tags
  33008. * @param tagsQuery defines the tags query to use
  33009. * @param forEach defines a predicate used to filter results
  33010. * @returns an array of Mesh
  33011. */
  33012. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33013. /**
  33014. * Get a list of cameras by tags
  33015. * @param tagsQuery defines the tags query to use
  33016. * @param forEach defines a predicate used to filter results
  33017. * @returns an array of Camera
  33018. */
  33019. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33020. /**
  33021. * Get a list of lights by tags
  33022. * @param tagsQuery defines the tags query to use
  33023. * @param forEach defines a predicate used to filter results
  33024. * @returns an array of Light
  33025. */
  33026. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33027. /**
  33028. * Get a list of materials by tags
  33029. * @param tagsQuery defines the tags query to use
  33030. * @param forEach defines a predicate used to filter results
  33031. * @returns an array of Material
  33032. */
  33033. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33034. /**
  33035. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33036. * This allowed control for front to back rendering or reversly depending of the special needs.
  33037. *
  33038. * @param renderingGroupId The rendering group id corresponding to its index
  33039. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33040. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33041. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33042. */
  33043. 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;
  33044. /**
  33045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33046. *
  33047. * @param renderingGroupId The rendering group id corresponding to its index
  33048. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33049. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33050. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33051. */
  33052. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33053. /**
  33054. * Gets the current auto clear configuration for one rendering group of the rendering
  33055. * manager.
  33056. * @param index the rendering group index to get the information for
  33057. * @returns The auto clear setup for the requested rendering group
  33058. */
  33059. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33060. private _blockMaterialDirtyMechanism;
  33061. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33062. blockMaterialDirtyMechanism: boolean;
  33063. /**
  33064. * Will flag all materials as dirty to trigger new shader compilation
  33065. * @param flag defines the flag used to specify which material part must be marked as dirty
  33066. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33067. */
  33068. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33069. /** @hidden */ private _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;
  33070. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33071. }
  33072. }
  33073. declare module BABYLON {
  33074. /**
  33075. * Set of assets to keep when moving a scene into an asset container.
  33076. */
  33077. export class KeepAssets extends AbstractScene {
  33078. }
  33079. /**
  33080. * Container with a set of assets that can be added or removed from a scene.
  33081. */
  33082. export class AssetContainer extends AbstractScene {
  33083. /**
  33084. * The scene the AssetContainer belongs to.
  33085. */
  33086. scene: Scene;
  33087. /**
  33088. * Instantiates an AssetContainer.
  33089. * @param scene The scene the AssetContainer belongs to.
  33090. */
  33091. constructor(scene: Scene);
  33092. /**
  33093. * Adds all the assets from the container to the scene.
  33094. */
  33095. addAllToScene(): void;
  33096. /**
  33097. * Removes all the assets in the container from the scene
  33098. */
  33099. removeAllFromScene(): void;
  33100. /**
  33101. * Disposes all the assets in the container
  33102. */
  33103. dispose(): void;
  33104. private _moveAssets;
  33105. /**
  33106. * Removes all the assets contained in the scene and adds them to the container.
  33107. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33108. */
  33109. moveAllFromScene(keepAssets?: KeepAssets): void;
  33110. /**
  33111. * 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.
  33112. * @returns the root mesh
  33113. */
  33114. createRootMesh(): Mesh;
  33115. }
  33116. }
  33117. declare module BABYLON {
  33118. /**
  33119. * Defines how the parser contract is defined.
  33120. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33121. */
  33122. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33123. /**
  33124. * Defines how the individual parser contract is defined.
  33125. * These parser can parse an individual asset
  33126. */
  33127. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33128. /**
  33129. * Base class of the scene acting as a container for the different elements composing a scene.
  33130. * This class is dynamically extended by the different components of the scene increasing
  33131. * flexibility and reducing coupling
  33132. */
  33133. export abstract class AbstractScene {
  33134. /**
  33135. * Stores the list of available parsers in the application.
  33136. */
  33137. private static _BabylonFileParsers;
  33138. /**
  33139. * Stores the list of available individual parsers in the application.
  33140. */
  33141. private static _IndividualBabylonFileParsers;
  33142. /**
  33143. * Adds a parser in the list of available ones
  33144. * @param name Defines the name of the parser
  33145. * @param parser Defines the parser to add
  33146. */
  33147. static AddParser(name: string, parser: BabylonFileParser): void;
  33148. /**
  33149. * Gets a general parser from the list of avaialble ones
  33150. * @param name Defines the name of the parser
  33151. * @returns the requested parser or null
  33152. */
  33153. static GetParser(name: string): Nullable<BabylonFileParser>;
  33154. /**
  33155. * Adds n individual parser in the list of available ones
  33156. * @param name Defines the name of the parser
  33157. * @param parser Defines the parser to add
  33158. */
  33159. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33160. /**
  33161. * Gets an individual parser from the list of avaialble ones
  33162. * @param name Defines the name of the parser
  33163. * @returns the requested parser or null
  33164. */
  33165. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33166. /**
  33167. * Parser json data and populate both a scene and its associated container object
  33168. * @param jsonData Defines the data to parse
  33169. * @param scene Defines the scene to parse the data for
  33170. * @param container Defines the container attached to the parsing sequence
  33171. * @param rootUrl Defines the root url of the data
  33172. */
  33173. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33174. /**
  33175. * Gets the list of root nodes (ie. nodes with no parent)
  33176. */
  33177. rootNodes: Node[];
  33178. /** All of the cameras added to this scene
  33179. * @see http://doc.babylonjs.com/babylon101/cameras
  33180. */
  33181. cameras: Camera[];
  33182. /**
  33183. * All of the lights added to this scene
  33184. * @see http://doc.babylonjs.com/babylon101/lights
  33185. */
  33186. lights: Light[];
  33187. /**
  33188. * All of the (abstract) meshes added to this scene
  33189. */
  33190. meshes: AbstractMesh[];
  33191. /**
  33192. * The list of skeletons added to the scene
  33193. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33194. */
  33195. skeletons: Skeleton[];
  33196. /**
  33197. * All of the particle systems added to this scene
  33198. * @see http://doc.babylonjs.com/babylon101/particles
  33199. */
  33200. particleSystems: IParticleSystem[];
  33201. /**
  33202. * Gets a list of Animations associated with the scene
  33203. */
  33204. animations: Animation[];
  33205. /**
  33206. * All of the animation groups added to this scene
  33207. * @see http://doc.babylonjs.com/how_to/group
  33208. */
  33209. animationGroups: AnimationGroup[];
  33210. /**
  33211. * All of the multi-materials added to this scene
  33212. * @see http://doc.babylonjs.com/how_to/multi_materials
  33213. */
  33214. multiMaterials: MultiMaterial[];
  33215. /**
  33216. * All of the materials added to this scene
  33217. * In the context of a Scene, it is not supposed to be modified manually.
  33218. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33219. * Note also that the order of the Material wihin the array is not significant and might change.
  33220. * @see http://doc.babylonjs.com/babylon101/materials
  33221. */
  33222. materials: Material[];
  33223. /**
  33224. * The list of morph target managers added to the scene
  33225. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33226. */
  33227. morphTargetManagers: MorphTargetManager[];
  33228. /**
  33229. * The list of geometries used in the scene.
  33230. */
  33231. geometries: Geometry[];
  33232. /**
  33233. * All of the tranform nodes added to this scene
  33234. * In the context of a Scene, it is not supposed to be modified manually.
  33235. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33236. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33237. * @see http://doc.babylonjs.com/how_to/transformnode
  33238. */
  33239. transformNodes: TransformNode[];
  33240. /**
  33241. * ActionManagers available on the scene.
  33242. */
  33243. actionManagers: AbstractActionManager[];
  33244. /**
  33245. * Textures to keep.
  33246. */
  33247. textures: BaseTexture[];
  33248. /**
  33249. * Environment texture for the scene
  33250. */
  33251. environmentTexture: Nullable<BaseTexture>;
  33252. }
  33253. }
  33254. declare module BABYLON {
  33255. /**
  33256. * Defines a sound that can be played in the application.
  33257. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33259. */
  33260. export class Sound {
  33261. /**
  33262. * The name of the sound in the scene.
  33263. */
  33264. name: string;
  33265. /**
  33266. * Does the sound autoplay once loaded.
  33267. */
  33268. autoplay: boolean;
  33269. /**
  33270. * Does the sound loop after it finishes playing once.
  33271. */
  33272. loop: boolean;
  33273. /**
  33274. * Does the sound use a custom attenuation curve to simulate the falloff
  33275. * happening when the source gets further away from the camera.
  33276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33277. */
  33278. useCustomAttenuation: boolean;
  33279. /**
  33280. * The sound track id this sound belongs to.
  33281. */
  33282. soundTrackId: number;
  33283. /**
  33284. * Is this sound currently played.
  33285. */
  33286. isPlaying: boolean;
  33287. /**
  33288. * Is this sound currently paused.
  33289. */
  33290. isPaused: boolean;
  33291. /**
  33292. * Does this sound enables spatial sound.
  33293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33294. */
  33295. spatialSound: boolean;
  33296. /**
  33297. * Define the reference distance the sound should be heard perfectly.
  33298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33299. */
  33300. refDistance: number;
  33301. /**
  33302. * Define the roll off factor of spatial sounds.
  33303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33304. */
  33305. rolloffFactor: number;
  33306. /**
  33307. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33309. */
  33310. maxDistance: number;
  33311. /**
  33312. * Define the distance attenuation model the sound will follow.
  33313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33314. */
  33315. distanceModel: string;
  33316. /**
  33317. * @hidden
  33318. * Back Compat
  33319. **/
  33320. onended: () => any;
  33321. /**
  33322. * Observable event when the current playing sound finishes.
  33323. */
  33324. onEndedObservable: Observable<Sound>;
  33325. private _panningModel;
  33326. private _playbackRate;
  33327. private _streaming;
  33328. private _startTime;
  33329. private _startOffset;
  33330. private _position;
  33331. /** @hidden */ private _positionInEmitterSpace: boolean;
  33332. private _localDirection;
  33333. private _volume;
  33334. private _isReadyToPlay;
  33335. private _isDirectional;
  33336. private _readyToPlayCallback;
  33337. private _audioBuffer;
  33338. private _soundSource;
  33339. private _streamingSource;
  33340. private _soundPanner;
  33341. private _soundGain;
  33342. private _inputAudioNode;
  33343. private _outputAudioNode;
  33344. private _coneInnerAngle;
  33345. private _coneOuterAngle;
  33346. private _coneOuterGain;
  33347. private _scene;
  33348. private _connectedTransformNode;
  33349. private _customAttenuationFunction;
  33350. private _registerFunc;
  33351. private _isOutputConnected;
  33352. private _htmlAudioElement;
  33353. private _urlType;
  33354. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33355. /**
  33356. * Create a sound and attach it to a scene
  33357. * @param name Name of your sound
  33358. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33359. * @param scene defines the scene the sound belongs to
  33360. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33361. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33362. */
  33363. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33364. /**
  33365. * Release the sound and its associated resources
  33366. */
  33367. dispose(): void;
  33368. /**
  33369. * Gets if the sounds is ready to be played or not.
  33370. * @returns true if ready, otherwise false
  33371. */
  33372. isReady(): boolean;
  33373. private _soundLoaded;
  33374. /**
  33375. * Sets the data of the sound from an audiobuffer
  33376. * @param audioBuffer The audioBuffer containing the data
  33377. */
  33378. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33379. /**
  33380. * Updates the current sounds options such as maxdistance, loop...
  33381. * @param options A JSON object containing values named as the object properties
  33382. */
  33383. updateOptions(options: any): void;
  33384. private _createSpatialParameters;
  33385. private _updateSpatialParameters;
  33386. /**
  33387. * Switch the panning model to HRTF:
  33388. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33390. */
  33391. switchPanningModelToHRTF(): void;
  33392. /**
  33393. * Switch the panning model to Equal Power:
  33394. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33396. */
  33397. switchPanningModelToEqualPower(): void;
  33398. private _switchPanningModel;
  33399. /**
  33400. * Connect this sound to a sound track audio node like gain...
  33401. * @param soundTrackAudioNode the sound track audio node to connect to
  33402. */
  33403. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33404. /**
  33405. * Transform this sound into a directional source
  33406. * @param coneInnerAngle Size of the inner cone in degree
  33407. * @param coneOuterAngle Size of the outer cone in degree
  33408. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33409. */
  33410. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33411. /**
  33412. * Gets or sets the inner angle for the directional cone.
  33413. */
  33414. /**
  33415. * Gets or sets the inner angle for the directional cone.
  33416. */
  33417. directionalConeInnerAngle: number;
  33418. /**
  33419. * Gets or sets the outer angle for the directional cone.
  33420. */
  33421. /**
  33422. * Gets or sets the outer angle for the directional cone.
  33423. */
  33424. directionalConeOuterAngle: number;
  33425. /**
  33426. * Sets the position of the emitter if spatial sound is enabled
  33427. * @param newPosition Defines the new posisiton
  33428. */
  33429. setPosition(newPosition: Vector3): void;
  33430. /**
  33431. * Sets the local direction of the emitter if spatial sound is enabled
  33432. * @param newLocalDirection Defines the new local direction
  33433. */
  33434. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33435. private _updateDirection;
  33436. /** @hidden */
  33437. updateDistanceFromListener(): void;
  33438. /**
  33439. * Sets a new custom attenuation function for the sound.
  33440. * @param callback Defines the function used for the attenuation
  33441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33442. */
  33443. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33444. /**
  33445. * Play the sound
  33446. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33447. * @param offset (optional) Start the sound setting it at a specific time
  33448. */
  33449. play(time?: number, offset?: number): void;
  33450. private _onended;
  33451. /**
  33452. * Stop the sound
  33453. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33454. */
  33455. stop(time?: number): void;
  33456. /**
  33457. * Put the sound in pause
  33458. */
  33459. pause(): void;
  33460. /**
  33461. * Sets a dedicated volume for this sounds
  33462. * @param newVolume Define the new volume of the sound
  33463. * @param time Define in how long the sound should be at this value
  33464. */
  33465. setVolume(newVolume: number, time?: number): void;
  33466. /**
  33467. * Set the sound play back rate
  33468. * @param newPlaybackRate Define the playback rate the sound should be played at
  33469. */
  33470. setPlaybackRate(newPlaybackRate: number): void;
  33471. /**
  33472. * Gets the volume of the sound.
  33473. * @returns the volume of the sound
  33474. */
  33475. getVolume(): number;
  33476. /**
  33477. * Attach the sound to a dedicated mesh
  33478. * @param transformNode The transform node to connect the sound with
  33479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33480. */
  33481. attachToMesh(transformNode: TransformNode): void;
  33482. /**
  33483. * Detach the sound from the previously attached mesh
  33484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33485. */
  33486. detachFromMesh(): void;
  33487. private _onRegisterAfterWorldMatrixUpdate;
  33488. /**
  33489. * Clone the current sound in the scene.
  33490. * @returns the new sound clone
  33491. */
  33492. clone(): Nullable<Sound>;
  33493. /**
  33494. * Gets the current underlying audio buffer containing the data
  33495. * @returns the audio buffer
  33496. */
  33497. getAudioBuffer(): Nullable<AudioBuffer>;
  33498. /**
  33499. * Serializes the Sound in a JSON representation
  33500. * @returns the JSON representation of the sound
  33501. */
  33502. serialize(): any;
  33503. /**
  33504. * Parse a JSON representation of a sound to innstantiate in a given scene
  33505. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33506. * @param scene Define the scene the new parsed sound should be created in
  33507. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33508. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33509. * @returns the newly parsed sound
  33510. */
  33511. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33512. }
  33513. }
  33514. declare module BABYLON {
  33515. /**
  33516. * This defines an action helpful to play a defined sound on a triggered action.
  33517. */
  33518. export class PlaySoundAction extends Action {
  33519. private _sound;
  33520. /**
  33521. * Instantiate the action
  33522. * @param triggerOptions defines the trigger options
  33523. * @param sound defines the sound to play
  33524. * @param condition defines the trigger related conditions
  33525. */
  33526. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33527. /** @hidden */ private _prepare(): void;
  33528. /**
  33529. * Execute the action and play the sound.
  33530. */
  33531. execute(): void;
  33532. /**
  33533. * Serializes the actions and its related information.
  33534. * @param parent defines the object to serialize in
  33535. * @returns the serialized object
  33536. */
  33537. serialize(parent: any): any;
  33538. }
  33539. /**
  33540. * This defines an action helpful to stop a defined sound on a triggered action.
  33541. */
  33542. export class StopSoundAction extends Action {
  33543. private _sound;
  33544. /**
  33545. * Instantiate the action
  33546. * @param triggerOptions defines the trigger options
  33547. * @param sound defines the sound to stop
  33548. * @param condition defines the trigger related conditions
  33549. */
  33550. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33551. /** @hidden */ private _prepare(): void;
  33552. /**
  33553. * Execute the action and stop the sound.
  33554. */
  33555. execute(): void;
  33556. /**
  33557. * Serializes the actions and its related information.
  33558. * @param parent defines the object to serialize in
  33559. * @returns the serialized object
  33560. */
  33561. serialize(parent: any): any;
  33562. }
  33563. }
  33564. declare module BABYLON {
  33565. /**
  33566. * This defines an action responsible to change the value of a property
  33567. * by interpolating between its current value and the newly set one once triggered.
  33568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33569. */
  33570. export class InterpolateValueAction extends Action {
  33571. /**
  33572. * Defines the path of the property where the value should be interpolated
  33573. */
  33574. propertyPath: string;
  33575. /**
  33576. * Defines the target value at the end of the interpolation.
  33577. */
  33578. value: any;
  33579. /**
  33580. * Defines the time it will take for the property to interpolate to the value.
  33581. */
  33582. duration: number;
  33583. /**
  33584. * Defines if the other scene animations should be stopped when the action has been triggered
  33585. */
  33586. stopOtherAnimations?: boolean;
  33587. /**
  33588. * Defines a callback raised once the interpolation animation has been done.
  33589. */
  33590. onInterpolationDone?: () => void;
  33591. /**
  33592. * Observable triggered once the interpolation animation has been done.
  33593. */
  33594. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33595. private _target;
  33596. private _effectiveTarget;
  33597. private _property;
  33598. /**
  33599. * Instantiate the action
  33600. * @param triggerOptions defines the trigger options
  33601. * @param target defines the object containing the value to interpolate
  33602. * @param propertyPath defines the path to the property in the target object
  33603. * @param value defines the target value at the end of the interpolation
  33604. * @param duration deines the time it will take for the property to interpolate to the value.
  33605. * @param condition defines the trigger related conditions
  33606. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33607. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33608. */
  33609. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33610. /** @hidden */ private _prepare(): void;
  33611. /**
  33612. * Execute the action starts the value interpolation.
  33613. */
  33614. execute(): void;
  33615. /**
  33616. * Serializes the actions and its related information.
  33617. * @param parent defines the object to serialize in
  33618. * @returns the serialized object
  33619. */
  33620. serialize(parent: any): any;
  33621. }
  33622. }
  33623. declare module BABYLON {
  33624. /**
  33625. * Options allowed during the creation of a sound track.
  33626. */
  33627. export interface ISoundTrackOptions {
  33628. /**
  33629. * The volume the sound track should take during creation
  33630. */
  33631. volume?: number;
  33632. /**
  33633. * Define if the sound track is the main sound track of the scene
  33634. */
  33635. mainTrack?: boolean;
  33636. }
  33637. /**
  33638. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33639. * It will be also used in a future release to apply effects on a specific track.
  33640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33641. */
  33642. export class SoundTrack {
  33643. /**
  33644. * The unique identifier of the sound track in the scene.
  33645. */
  33646. id: number;
  33647. /**
  33648. * The list of sounds included in the sound track.
  33649. */
  33650. soundCollection: Array<Sound>;
  33651. private _outputAudioNode;
  33652. private _scene;
  33653. private _isMainTrack;
  33654. private _connectedAnalyser;
  33655. private _options;
  33656. private _isInitialized;
  33657. /**
  33658. * Creates a new sound track.
  33659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33660. * @param scene Define the scene the sound track belongs to
  33661. * @param options
  33662. */
  33663. constructor(scene: Scene, options?: ISoundTrackOptions);
  33664. private _initializeSoundTrackAudioGraph;
  33665. /**
  33666. * Release the sound track and its associated resources
  33667. */
  33668. dispose(): void;
  33669. /**
  33670. * Adds a sound to this sound track
  33671. * @param sound define the cound to add
  33672. * @ignoreNaming
  33673. */
  33674. AddSound(sound: Sound): void;
  33675. /**
  33676. * Removes a sound to this sound track
  33677. * @param sound define the cound to remove
  33678. * @ignoreNaming
  33679. */
  33680. RemoveSound(sound: Sound): void;
  33681. /**
  33682. * Set a global volume for the full sound track.
  33683. * @param newVolume Define the new volume of the sound track
  33684. */
  33685. setVolume(newVolume: number): void;
  33686. /**
  33687. * Switch the panning model to HRTF:
  33688. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33690. */
  33691. switchPanningModelToHRTF(): void;
  33692. /**
  33693. * Switch the panning model to Equal Power:
  33694. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33696. */
  33697. switchPanningModelToEqualPower(): void;
  33698. /**
  33699. * Connect the sound track to an audio analyser allowing some amazing
  33700. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33702. * @param analyser The analyser to connect to the engine
  33703. */
  33704. connectToAnalyser(analyser: Analyser): void;
  33705. }
  33706. }
  33707. declare module BABYLON {
  33708. interface AbstractScene {
  33709. /**
  33710. * The list of sounds used in the scene.
  33711. */
  33712. sounds: Nullable<Array<Sound>>;
  33713. }
  33714. interface Scene {
  33715. /**
  33716. * @hidden
  33717. * Backing field
  33718. */ private _mainSoundTrack: SoundTrack;
  33719. /**
  33720. * The main sound track played by the scene.
  33721. * It cotains your primary collection of sounds.
  33722. */
  33723. mainSoundTrack: SoundTrack;
  33724. /**
  33725. * The list of sound tracks added to the scene
  33726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33727. */
  33728. soundTracks: Nullable<Array<SoundTrack>>;
  33729. /**
  33730. * Gets a sound using a given name
  33731. * @param name defines the name to search for
  33732. * @return the found sound or null if not found at all.
  33733. */
  33734. getSoundByName(name: string): Nullable<Sound>;
  33735. /**
  33736. * Gets or sets if audio support is enabled
  33737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33738. */
  33739. audioEnabled: boolean;
  33740. /**
  33741. * Gets or sets if audio will be output to headphones
  33742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33743. */
  33744. headphone: boolean;
  33745. }
  33746. /**
  33747. * Defines the sound scene component responsible to manage any sounds
  33748. * in a given scene.
  33749. */
  33750. export class AudioSceneComponent implements ISceneSerializableComponent {
  33751. /**
  33752. * The component name helpfull to identify the component in the list of scene components.
  33753. */
  33754. readonly name: string;
  33755. /**
  33756. * The scene the component belongs to.
  33757. */
  33758. scene: Scene;
  33759. private _audioEnabled;
  33760. /**
  33761. * Gets whether audio is enabled or not.
  33762. * Please use related enable/disable method to switch state.
  33763. */
  33764. readonly audioEnabled: boolean;
  33765. private _headphone;
  33766. /**
  33767. * Gets whether audio is outputing to headphone or not.
  33768. * Please use the according Switch methods to change output.
  33769. */
  33770. readonly headphone: boolean;
  33771. /**
  33772. * Creates a new instance of the component for the given scene
  33773. * @param scene Defines the scene to register the component in
  33774. */
  33775. constructor(scene: Scene);
  33776. /**
  33777. * Registers the component in a given scene
  33778. */
  33779. register(): void;
  33780. /**
  33781. * Rebuilds the elements related to this component in case of
  33782. * context lost for instance.
  33783. */
  33784. rebuild(): void;
  33785. /**
  33786. * Serializes the component data to the specified json object
  33787. * @param serializationObject The object to serialize to
  33788. */
  33789. serialize(serializationObject: any): void;
  33790. /**
  33791. * Adds all the element from the container to the scene
  33792. * @param container the container holding the elements
  33793. */
  33794. addFromContainer(container: AbstractScene): void;
  33795. /**
  33796. * Removes all the elements in the container from the scene
  33797. * @param container contains the elements to remove
  33798. * @param dispose if the removed element should be disposed (default: false)
  33799. */
  33800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33801. /**
  33802. * Disposes the component and the associated ressources.
  33803. */
  33804. dispose(): void;
  33805. /**
  33806. * Disables audio in the associated scene.
  33807. */
  33808. disableAudio(): void;
  33809. /**
  33810. * Enables audio in the associated scene.
  33811. */
  33812. enableAudio(): void;
  33813. /**
  33814. * Switch audio to headphone output.
  33815. */
  33816. switchAudioModeForHeadphones(): void;
  33817. /**
  33818. * Switch audio to normal speakers.
  33819. */
  33820. switchAudioModeForNormalSpeakers(): void;
  33821. private _afterRender;
  33822. }
  33823. }
  33824. declare module BABYLON {
  33825. /**
  33826. * Wraps one or more Sound objects and selects one with random weight for playback.
  33827. */
  33828. export class WeightedSound {
  33829. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33830. loop: boolean;
  33831. private _coneInnerAngle;
  33832. private _coneOuterAngle;
  33833. private _volume;
  33834. /** A Sound is currently playing. */
  33835. isPlaying: boolean;
  33836. /** A Sound is currently paused. */
  33837. isPaused: boolean;
  33838. private _sounds;
  33839. private _weights;
  33840. private _currentIndex?;
  33841. /**
  33842. * Creates a new WeightedSound from the list of sounds given.
  33843. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33844. * @param sounds Array of Sounds that will be selected from.
  33845. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33846. */
  33847. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33848. /**
  33849. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33850. */
  33851. /**
  33852. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33853. */
  33854. directionalConeInnerAngle: number;
  33855. /**
  33856. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33857. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33858. */
  33859. /**
  33860. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33861. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33862. */
  33863. directionalConeOuterAngle: number;
  33864. /**
  33865. * Playback volume.
  33866. */
  33867. /**
  33868. * Playback volume.
  33869. */
  33870. volume: number;
  33871. private _onended;
  33872. /**
  33873. * Suspend playback
  33874. */
  33875. pause(): void;
  33876. /**
  33877. * Stop playback
  33878. */
  33879. stop(): void;
  33880. /**
  33881. * Start playback.
  33882. * @param startOffset Position the clip head at a specific time in seconds.
  33883. */
  33884. play(startOffset?: number): void;
  33885. }
  33886. }
  33887. declare module BABYLON {
  33888. /**
  33889. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33890. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33891. */
  33892. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33893. /**
  33894. * Gets the name of the behavior.
  33895. */
  33896. readonly name: string;
  33897. /**
  33898. * The easing function used by animations
  33899. */
  33900. static EasingFunction: BackEase;
  33901. /**
  33902. * The easing mode used by animations
  33903. */
  33904. static EasingMode: number;
  33905. /**
  33906. * The duration of the animation, in milliseconds
  33907. */
  33908. transitionDuration: number;
  33909. /**
  33910. * Length of the distance animated by the transition when lower radius is reached
  33911. */
  33912. lowerRadiusTransitionRange: number;
  33913. /**
  33914. * Length of the distance animated by the transition when upper radius is reached
  33915. */
  33916. upperRadiusTransitionRange: number;
  33917. private _autoTransitionRange;
  33918. /**
  33919. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33920. */
  33921. /**
  33922. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33923. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33924. */
  33925. autoTransitionRange: boolean;
  33926. private _attachedCamera;
  33927. private _onAfterCheckInputsObserver;
  33928. private _onMeshTargetChangedObserver;
  33929. /**
  33930. * Initializes the behavior.
  33931. */
  33932. init(): void;
  33933. /**
  33934. * Attaches the behavior to its arc rotate camera.
  33935. * @param camera Defines the camera to attach the behavior to
  33936. */
  33937. attach(camera: ArcRotateCamera): void;
  33938. /**
  33939. * Detaches the behavior from its current arc rotate camera.
  33940. */
  33941. detach(): void;
  33942. private _radiusIsAnimating;
  33943. private _radiusBounceTransition;
  33944. private _animatables;
  33945. private _cachedWheelPrecision;
  33946. /**
  33947. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33948. * @param radiusLimit The limit to check against.
  33949. * @return Bool to indicate if at limit.
  33950. */
  33951. private _isRadiusAtLimit;
  33952. /**
  33953. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33954. * @param radiusDelta The delta by which to animate to. Can be negative.
  33955. */
  33956. private _applyBoundRadiusAnimation;
  33957. /**
  33958. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33959. */
  33960. protected _clearAnimationLocks(): void;
  33961. /**
  33962. * Stops and removes all animations that have been applied to the camera
  33963. */
  33964. stopAllAnimations(): void;
  33965. }
  33966. }
  33967. declare module BABYLON {
  33968. /**
  33969. * 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.
  33970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33971. */
  33972. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33973. /**
  33974. * Gets the name of the behavior.
  33975. */
  33976. readonly name: string;
  33977. private _mode;
  33978. private _radiusScale;
  33979. private _positionScale;
  33980. private _defaultElevation;
  33981. private _elevationReturnTime;
  33982. private _elevationReturnWaitTime;
  33983. private _zoomStopsAnimation;
  33984. private _framingTime;
  33985. /**
  33986. * The easing function used by animations
  33987. */
  33988. static EasingFunction: ExponentialEase;
  33989. /**
  33990. * The easing mode used by animations
  33991. */
  33992. static EasingMode: number;
  33993. /**
  33994. * Sets the current mode used by the behavior
  33995. */
  33996. /**
  33997. * Gets current mode used by the behavior.
  33998. */
  33999. mode: number;
  34000. /**
  34001. * Sets the scale applied to the radius (1 by default)
  34002. */
  34003. /**
  34004. * Gets the scale applied to the radius
  34005. */
  34006. radiusScale: number;
  34007. /**
  34008. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34009. */
  34010. /**
  34011. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34012. */
  34013. positionScale: number;
  34014. /**
  34015. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34016. * behaviour is triggered, in radians.
  34017. */
  34018. /**
  34019. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34020. * behaviour is triggered, in radians.
  34021. */
  34022. defaultElevation: number;
  34023. /**
  34024. * Sets the time (in milliseconds) taken to return to the default beta position.
  34025. * Negative value indicates camera should not return to default.
  34026. */
  34027. /**
  34028. * Gets the time (in milliseconds) taken to return to the default beta position.
  34029. * Negative value indicates camera should not return to default.
  34030. */
  34031. elevationReturnTime: number;
  34032. /**
  34033. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34034. */
  34035. /**
  34036. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34037. */
  34038. elevationReturnWaitTime: number;
  34039. /**
  34040. * Sets the flag that indicates if user zooming should stop animation.
  34041. */
  34042. /**
  34043. * Gets the flag that indicates if user zooming should stop animation.
  34044. */
  34045. zoomStopsAnimation: boolean;
  34046. /**
  34047. * Sets the transition time when framing the mesh, in milliseconds
  34048. */
  34049. /**
  34050. * Gets the transition time when framing the mesh, in milliseconds
  34051. */
  34052. framingTime: number;
  34053. /**
  34054. * Define if the behavior should automatically change the configured
  34055. * camera limits and sensibilities.
  34056. */
  34057. autoCorrectCameraLimitsAndSensibility: boolean;
  34058. private _onPrePointerObservableObserver;
  34059. private _onAfterCheckInputsObserver;
  34060. private _onMeshTargetChangedObserver;
  34061. private _attachedCamera;
  34062. private _isPointerDown;
  34063. private _lastInteractionTime;
  34064. /**
  34065. * Initializes the behavior.
  34066. */
  34067. init(): void;
  34068. /**
  34069. * Attaches the behavior to its arc rotate camera.
  34070. * @param camera Defines the camera to attach the behavior to
  34071. */
  34072. attach(camera: ArcRotateCamera): void;
  34073. /**
  34074. * Detaches the behavior from its current arc rotate camera.
  34075. */
  34076. detach(): void;
  34077. private _animatables;
  34078. private _betaIsAnimating;
  34079. private _betaTransition;
  34080. private _radiusTransition;
  34081. private _vectorTransition;
  34082. /**
  34083. * Targets the given mesh and updates zoom level accordingly.
  34084. * @param mesh The mesh to target.
  34085. * @param radius Optional. If a cached radius position already exists, overrides default.
  34086. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34087. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34088. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34089. */
  34090. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34091. /**
  34092. * Targets the given mesh with its children and updates zoom level accordingly.
  34093. * @param mesh The mesh to target.
  34094. * @param radius Optional. If a cached radius position already exists, overrides default.
  34095. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34096. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34097. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34098. */
  34099. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34100. /**
  34101. * Targets the given meshes with their children and updates zoom level accordingly.
  34102. * @param meshes The mesh to target.
  34103. * @param radius Optional. If a cached radius position already exists, overrides default.
  34104. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34105. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34106. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34107. */
  34108. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34109. /**
  34110. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34111. * @param minimumWorld Determines the smaller position of the bounding box extend
  34112. * @param maximumWorld Determines the bigger position of the bounding box extend
  34113. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34114. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34115. */
  34116. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34117. /**
  34118. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34119. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34120. * frustum width.
  34121. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34122. * to fully enclose the mesh in the viewing frustum.
  34123. */
  34124. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34125. /**
  34126. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34127. * is automatically returned to its default position (expected to be above ground plane).
  34128. */
  34129. private _maintainCameraAboveGround;
  34130. /**
  34131. * Returns the frustum slope based on the canvas ratio and camera FOV
  34132. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34133. */
  34134. private _getFrustumSlope;
  34135. /**
  34136. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34137. */
  34138. private _clearAnimationLocks;
  34139. /**
  34140. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34141. */
  34142. private _applyUserInteraction;
  34143. /**
  34144. * Stops and removes all animations that have been applied to the camera
  34145. */
  34146. stopAllAnimations(): void;
  34147. /**
  34148. * Gets a value indicating if the user is moving the camera
  34149. */
  34150. readonly isUserIsMoving: boolean;
  34151. /**
  34152. * The camera can move all the way towards the mesh.
  34153. */
  34154. static IgnoreBoundsSizeMode: number;
  34155. /**
  34156. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34157. */
  34158. static FitFrustumSidesMode: number;
  34159. }
  34160. }
  34161. declare module BABYLON {
  34162. /**
  34163. * Base class for Camera Pointer Inputs.
  34164. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34165. * for example usage.
  34166. */
  34167. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34168. /**
  34169. * Defines the camera the input is attached to.
  34170. */
  34171. abstract camera: Camera;
  34172. /**
  34173. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34174. */
  34175. protected _altKey: boolean;
  34176. protected _ctrlKey: boolean;
  34177. protected _metaKey: boolean;
  34178. protected _shiftKey: boolean;
  34179. /**
  34180. * Which mouse buttons were pressed at time of last mouse event.
  34181. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34182. */
  34183. protected _buttonsPressed: number;
  34184. /**
  34185. * Defines the buttons associated with the input to handle camera move.
  34186. */
  34187. buttons: number[];
  34188. /**
  34189. * Attach the input controls to a specific dom element to get the input from.
  34190. * @param element Defines the element the controls should be listened from
  34191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34192. */
  34193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34194. /**
  34195. * Detach the current controls from the specified dom element.
  34196. * @param element Defines the element to stop listening the inputs from
  34197. */
  34198. detachControl(element: Nullable<HTMLElement>): void;
  34199. /**
  34200. * Gets the class name of the current input.
  34201. * @returns the class name
  34202. */
  34203. getClassName(): string;
  34204. /**
  34205. * Get the friendly name associated with the input class.
  34206. * @returns the input friendly name
  34207. */
  34208. getSimpleName(): string;
  34209. /**
  34210. * Called on pointer POINTERDOUBLETAP event.
  34211. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34212. */
  34213. protected onDoubleTap(type: string): void;
  34214. /**
  34215. * Called on pointer POINTERMOVE event if only a single touch is active.
  34216. * Override this method to provide functionality.
  34217. */
  34218. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34219. /**
  34220. * Called on pointer POINTERMOVE event if multiple touches are active.
  34221. * Override this method to provide functionality.
  34222. */
  34223. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34224. /**
  34225. * Called on JS contextmenu event.
  34226. * Override this method to provide functionality.
  34227. */
  34228. protected onContextMenu(evt: PointerEvent): void;
  34229. /**
  34230. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34231. * press.
  34232. * Override this method to provide functionality.
  34233. */
  34234. protected onButtonDown(evt: PointerEvent): void;
  34235. /**
  34236. * Called each time a new POINTERUP event occurs. Ie, for each button
  34237. * release.
  34238. * Override this method to provide functionality.
  34239. */
  34240. protected onButtonUp(evt: PointerEvent): void;
  34241. /**
  34242. * Called when window becomes inactive.
  34243. * Override this method to provide functionality.
  34244. */
  34245. protected onLostFocus(): void;
  34246. private _pointerInput;
  34247. private _observer;
  34248. private _onLostFocus;
  34249. private pointA;
  34250. private pointB;
  34251. }
  34252. }
  34253. declare module BABYLON {
  34254. /**
  34255. * Manage the pointers inputs to control an arc rotate camera.
  34256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34257. */
  34258. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34259. /**
  34260. * Defines the camera the input is attached to.
  34261. */
  34262. camera: ArcRotateCamera;
  34263. /**
  34264. * Gets the class name of the current input.
  34265. * @returns the class name
  34266. */
  34267. getClassName(): string;
  34268. /**
  34269. * Defines the buttons associated with the input to handle camera move.
  34270. */
  34271. buttons: number[];
  34272. /**
  34273. * Defines the pointer angular sensibility along the X axis or how fast is
  34274. * the camera rotating.
  34275. */
  34276. angularSensibilityX: number;
  34277. /**
  34278. * Defines the pointer angular sensibility along the Y axis or how fast is
  34279. * the camera rotating.
  34280. */
  34281. angularSensibilityY: number;
  34282. /**
  34283. * Defines the pointer pinch precision or how fast is the camera zooming.
  34284. */
  34285. pinchPrecision: number;
  34286. /**
  34287. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34288. * from 0.
  34289. * It defines the percentage of current camera.radius to use as delta when
  34290. * pinch zoom is used.
  34291. */
  34292. pinchDeltaPercentage: number;
  34293. /**
  34294. * Defines the pointer panning sensibility or how fast is the camera moving.
  34295. */
  34296. panningSensibility: number;
  34297. /**
  34298. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34299. */
  34300. multiTouchPanning: boolean;
  34301. /**
  34302. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34303. * zoom (pinch) through multitouch.
  34304. */
  34305. multiTouchPanAndZoom: boolean;
  34306. /**
  34307. * Revers pinch action direction.
  34308. */
  34309. pinchInwards: boolean;
  34310. private _isPanClick;
  34311. private _twoFingerActivityCount;
  34312. private _isPinching;
  34313. /**
  34314. * Called on pointer POINTERMOVE event if only a single touch is active.
  34315. */
  34316. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34317. /**
  34318. * Called on pointer POINTERDOUBLETAP event.
  34319. */
  34320. protected onDoubleTap(type: string): void;
  34321. /**
  34322. * Called on pointer POINTERMOVE event if multiple touches are active.
  34323. */
  34324. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34325. /**
  34326. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34327. * press.
  34328. */
  34329. protected onButtonDown(evt: PointerEvent): void;
  34330. /**
  34331. * Called each time a new POINTERUP event occurs. Ie, for each button
  34332. * release.
  34333. */
  34334. protected onButtonUp(evt: PointerEvent): void;
  34335. /**
  34336. * Called when window becomes inactive.
  34337. */
  34338. protected onLostFocus(): void;
  34339. }
  34340. }
  34341. declare module BABYLON {
  34342. /**
  34343. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34345. */
  34346. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34347. /**
  34348. * Defines the camera the input is attached to.
  34349. */
  34350. camera: ArcRotateCamera;
  34351. /**
  34352. * Defines the list of key codes associated with the up action (increase alpha)
  34353. */
  34354. keysUp: number[];
  34355. /**
  34356. * Defines the list of key codes associated with the down action (decrease alpha)
  34357. */
  34358. keysDown: number[];
  34359. /**
  34360. * Defines the list of key codes associated with the left action (increase beta)
  34361. */
  34362. keysLeft: number[];
  34363. /**
  34364. * Defines the list of key codes associated with the right action (decrease beta)
  34365. */
  34366. keysRight: number[];
  34367. /**
  34368. * Defines the list of key codes associated with the reset action.
  34369. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34370. */
  34371. keysReset: number[];
  34372. /**
  34373. * Defines the panning sensibility of the inputs.
  34374. * (How fast is the camera paning)
  34375. */
  34376. panningSensibility: number;
  34377. /**
  34378. * Defines the zooming sensibility of the inputs.
  34379. * (How fast is the camera zooming)
  34380. */
  34381. zoomingSensibility: number;
  34382. /**
  34383. * Defines wether maintaining the alt key down switch the movement mode from
  34384. * orientation to zoom.
  34385. */
  34386. useAltToZoom: boolean;
  34387. /**
  34388. * Rotation speed of the camera
  34389. */
  34390. angularSpeed: number;
  34391. private _keys;
  34392. private _ctrlPressed;
  34393. private _altPressed;
  34394. private _onCanvasBlurObserver;
  34395. private _onKeyboardObserver;
  34396. private _engine;
  34397. private _scene;
  34398. /**
  34399. * Attach the input controls to a specific dom element to get the input from.
  34400. * @param element Defines the element the controls should be listened from
  34401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34402. */
  34403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34404. /**
  34405. * Detach the current controls from the specified dom element.
  34406. * @param element Defines the element to stop listening the inputs from
  34407. */
  34408. detachControl(element: Nullable<HTMLElement>): void;
  34409. /**
  34410. * Update the current camera state depending on the inputs that have been used this frame.
  34411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34412. */
  34413. checkInputs(): void;
  34414. /**
  34415. * Gets the class name of the current intput.
  34416. * @returns the class name
  34417. */
  34418. getClassName(): string;
  34419. /**
  34420. * Get the friendly name associated with the input class.
  34421. * @returns the input friendly name
  34422. */
  34423. getSimpleName(): string;
  34424. }
  34425. }
  34426. declare module BABYLON {
  34427. /**
  34428. * Manage the mouse wheel inputs to control an arc rotate camera.
  34429. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34430. */
  34431. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34432. /**
  34433. * Defines the camera the input is attached to.
  34434. */
  34435. camera: ArcRotateCamera;
  34436. /**
  34437. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34438. */
  34439. wheelPrecision: number;
  34440. /**
  34441. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34442. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34443. */
  34444. wheelDeltaPercentage: number;
  34445. private _wheel;
  34446. private _observer;
  34447. private computeDeltaFromMouseWheelLegacyEvent;
  34448. /**
  34449. * Attach the input controls to a specific dom element to get the input from.
  34450. * @param element Defines the element the controls should be listened from
  34451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34452. */
  34453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34454. /**
  34455. * Detach the current controls from the specified dom element.
  34456. * @param element Defines the element to stop listening the inputs from
  34457. */
  34458. detachControl(element: Nullable<HTMLElement>): void;
  34459. /**
  34460. * Gets the class name of the current intput.
  34461. * @returns the class name
  34462. */
  34463. getClassName(): string;
  34464. /**
  34465. * Get the friendly name associated with the input class.
  34466. * @returns the input friendly name
  34467. */
  34468. getSimpleName(): string;
  34469. }
  34470. }
  34471. declare module BABYLON {
  34472. /**
  34473. * Default Inputs manager for the ArcRotateCamera.
  34474. * It groups all the default supported inputs for ease of use.
  34475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34476. */
  34477. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34478. /**
  34479. * Instantiates a new ArcRotateCameraInputsManager.
  34480. * @param camera Defines the camera the inputs belong to
  34481. */
  34482. constructor(camera: ArcRotateCamera);
  34483. /**
  34484. * Add mouse wheel input support to the input manager.
  34485. * @returns the current input manager
  34486. */
  34487. addMouseWheel(): ArcRotateCameraInputsManager;
  34488. /**
  34489. * Add pointers input support to the input manager.
  34490. * @returns the current input manager
  34491. */
  34492. addPointers(): ArcRotateCameraInputsManager;
  34493. /**
  34494. * Add keyboard input support to the input manager.
  34495. * @returns the current input manager
  34496. */
  34497. addKeyboard(): ArcRotateCameraInputsManager;
  34498. }
  34499. }
  34500. declare module BABYLON {
  34501. /**
  34502. * This represents an orbital type of camera.
  34503. *
  34504. * 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.
  34505. * 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.
  34506. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34507. */
  34508. export class ArcRotateCamera extends TargetCamera {
  34509. /**
  34510. * Defines the rotation angle of the camera along the longitudinal axis.
  34511. */
  34512. alpha: number;
  34513. /**
  34514. * Defines the rotation angle of the camera along the latitudinal axis.
  34515. */
  34516. beta: number;
  34517. /**
  34518. * Defines the radius of the camera from it s target point.
  34519. */
  34520. radius: number;
  34521. protected _target: Vector3;
  34522. protected _targetHost: Nullable<AbstractMesh>;
  34523. /**
  34524. * Defines the target point of the camera.
  34525. * The camera looks towards it form the radius distance.
  34526. */
  34527. target: Vector3;
  34528. /**
  34529. * Define the current local position of the camera in the scene
  34530. */
  34531. position: Vector3;
  34532. protected _upVector: Vector3;
  34533. protected _upToYMatrix: Matrix;
  34534. protected _YToUpMatrix: Matrix;
  34535. /**
  34536. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34537. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34538. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34539. */
  34540. upVector: Vector3;
  34541. /**
  34542. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34543. */
  34544. setMatUp(): void;
  34545. /**
  34546. * Current inertia value on the longitudinal axis.
  34547. * The bigger this number the longer it will take for the camera to stop.
  34548. */
  34549. inertialAlphaOffset: number;
  34550. /**
  34551. * Current inertia value on the latitudinal axis.
  34552. * The bigger this number the longer it will take for the camera to stop.
  34553. */
  34554. inertialBetaOffset: number;
  34555. /**
  34556. * Current inertia value on the radius axis.
  34557. * The bigger this number the longer it will take for the camera to stop.
  34558. */
  34559. inertialRadiusOffset: number;
  34560. /**
  34561. * Minimum allowed angle on the longitudinal axis.
  34562. * This can help limiting how the Camera is able to move in the scene.
  34563. */
  34564. lowerAlphaLimit: Nullable<number>;
  34565. /**
  34566. * Maximum allowed angle on the longitudinal axis.
  34567. * This can help limiting how the Camera is able to move in the scene.
  34568. */
  34569. upperAlphaLimit: Nullable<number>;
  34570. /**
  34571. * Minimum allowed angle on the latitudinal axis.
  34572. * This can help limiting how the Camera is able to move in the scene.
  34573. */
  34574. lowerBetaLimit: number;
  34575. /**
  34576. * Maximum allowed angle on the latitudinal axis.
  34577. * This can help limiting how the Camera is able to move in the scene.
  34578. */
  34579. upperBetaLimit: number;
  34580. /**
  34581. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34582. * This can help limiting how the Camera is able to move in the scene.
  34583. */
  34584. lowerRadiusLimit: Nullable<number>;
  34585. /**
  34586. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34587. * This can help limiting how the Camera is able to move in the scene.
  34588. */
  34589. upperRadiusLimit: Nullable<number>;
  34590. /**
  34591. * Defines the current inertia value used during panning of the camera along the X axis.
  34592. */
  34593. inertialPanningX: number;
  34594. /**
  34595. * Defines the current inertia value used during panning of the camera along the Y axis.
  34596. */
  34597. inertialPanningY: number;
  34598. /**
  34599. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34600. * Basically if your fingers moves away from more than this distance you will be considered
  34601. * in pinch mode.
  34602. */
  34603. pinchToPanMaxDistance: number;
  34604. /**
  34605. * Defines the maximum distance the camera can pan.
  34606. * This could help keeping the cammera always in your scene.
  34607. */
  34608. panningDistanceLimit: Nullable<number>;
  34609. /**
  34610. * Defines the target of the camera before paning.
  34611. */
  34612. panningOriginTarget: Vector3;
  34613. /**
  34614. * Defines the value of the inertia used during panning.
  34615. * 0 would mean stop inertia and one would mean no decelleration at all.
  34616. */
  34617. panningInertia: number;
  34618. /**
  34619. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34620. */
  34621. angularSensibilityX: number;
  34622. /**
  34623. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34624. */
  34625. angularSensibilityY: number;
  34626. /**
  34627. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34628. */
  34629. pinchPrecision: number;
  34630. /**
  34631. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34632. * It will be used instead of pinchDeltaPrecision if different from 0.
  34633. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34634. */
  34635. pinchDeltaPercentage: number;
  34636. /**
  34637. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34638. */
  34639. panningSensibility: number;
  34640. /**
  34641. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34642. */
  34643. keysUp: number[];
  34644. /**
  34645. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34646. */
  34647. keysDown: number[];
  34648. /**
  34649. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34650. */
  34651. keysLeft: number[];
  34652. /**
  34653. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34654. */
  34655. keysRight: number[];
  34656. /**
  34657. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34658. */
  34659. wheelPrecision: number;
  34660. /**
  34661. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34662. * It will be used instead of pinchDeltaPrecision if different from 0.
  34663. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34664. */
  34665. wheelDeltaPercentage: number;
  34666. /**
  34667. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34668. */
  34669. zoomOnFactor: number;
  34670. /**
  34671. * Defines a screen offset for the camera position.
  34672. */
  34673. targetScreenOffset: Vector2;
  34674. /**
  34675. * Allows the camera to be completely reversed.
  34676. * If false the camera can not arrive upside down.
  34677. */
  34678. allowUpsideDown: boolean;
  34679. /**
  34680. * Define if double tap/click is used to restore the previously saved state of the camera.
  34681. */
  34682. useInputToRestoreState: boolean;
  34683. /** @hidden */ private _viewMatrix: Matrix;
  34684. /** @hidden */ private _useCtrlForPanning: boolean;
  34685. /** @hidden */ private _panningMouseButton: number;
  34686. /**
  34687. * Defines the input associated to the camera.
  34688. */
  34689. inputs: ArcRotateCameraInputsManager;
  34690. /** @hidden */ private _reset: () => void;
  34691. /**
  34692. * Defines the allowed panning axis.
  34693. */
  34694. panningAxis: Vector3;
  34695. protected _localDirection: Vector3;
  34696. protected _transformedDirection: Vector3;
  34697. private _bouncingBehavior;
  34698. /**
  34699. * Gets the bouncing behavior of the camera if it has been enabled.
  34700. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34701. */
  34702. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34703. /**
  34704. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34705. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34706. */
  34707. useBouncingBehavior: boolean;
  34708. private _framingBehavior;
  34709. /**
  34710. * Gets the framing behavior of the camera if it has been enabled.
  34711. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34712. */
  34713. readonly framingBehavior: Nullable<FramingBehavior>;
  34714. /**
  34715. * Defines if the framing behavior of the camera is enabled on the camera.
  34716. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34717. */
  34718. useFramingBehavior: boolean;
  34719. private _autoRotationBehavior;
  34720. /**
  34721. * Gets the auto rotation behavior of the camera if it has been enabled.
  34722. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34723. */
  34724. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34725. /**
  34726. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34727. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34728. */
  34729. useAutoRotationBehavior: boolean;
  34730. /**
  34731. * Observable triggered when the mesh target has been changed on the camera.
  34732. */
  34733. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34734. /**
  34735. * Event raised when the camera is colliding with a mesh.
  34736. */
  34737. onCollide: (collidedMesh: AbstractMesh) => void;
  34738. /**
  34739. * Defines whether the camera should check collision with the objects oh the scene.
  34740. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34741. */
  34742. checkCollisions: boolean;
  34743. /**
  34744. * Defines the collision radius of the camera.
  34745. * This simulates a sphere around the camera.
  34746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34747. */
  34748. collisionRadius: Vector3;
  34749. protected _collider: Collider;
  34750. protected _previousPosition: Vector3;
  34751. protected _collisionVelocity: Vector3;
  34752. protected _newPosition: Vector3;
  34753. protected _previousAlpha: number;
  34754. protected _previousBeta: number;
  34755. protected _previousRadius: number;
  34756. protected _collisionTriggered: boolean;
  34757. protected _targetBoundingCenter: Nullable<Vector3>;
  34758. private _computationVector;
  34759. /**
  34760. * Instantiates a new ArcRotateCamera in a given scene
  34761. * @param name Defines the name of the camera
  34762. * @param alpha Defines the camera rotation along the logitudinal axis
  34763. * @param beta Defines the camera rotation along the latitudinal axis
  34764. * @param radius Defines the camera distance from its target
  34765. * @param target Defines the camera target
  34766. * @param scene Defines the scene the camera belongs to
  34767. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34768. */
  34769. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34770. /** @hidden */ private _initCache(): void;
  34771. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  34772. protected _getTargetPosition(): Vector3;
  34773. private _storedAlpha;
  34774. private _storedBeta;
  34775. private _storedRadius;
  34776. private _storedTarget;
  34777. /**
  34778. * Stores the current state of the camera (alpha, beta, radius and target)
  34779. * @returns the camera itself
  34780. */
  34781. storeState(): Camera;
  34782. /**
  34783. * @hidden
  34784. * Restored camera state. You must call storeState() first
  34785. */ private _restoreStateValues(): boolean;
  34786. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  34787. /**
  34788. * Attached controls to the current camera.
  34789. * @param element Defines the element the controls should be listened from
  34790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34791. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34792. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34793. */
  34794. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34795. /**
  34796. * Detach the current controls from the camera.
  34797. * The camera will stop reacting to inputs.
  34798. * @param element Defines the element to stop listening the inputs from
  34799. */
  34800. detachControl(element: HTMLElement): void;
  34801. /** @hidden */ private _checkInputs(): void;
  34802. protected _checkLimits(): void;
  34803. /**
  34804. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34805. */
  34806. rebuildAnglesAndRadius(): void;
  34807. /**
  34808. * Use a position to define the current camera related information like aplha, beta and radius
  34809. * @param position Defines the position to set the camera at
  34810. */
  34811. setPosition(position: Vector3): void;
  34812. /**
  34813. * Defines the target the camera should look at.
  34814. * This will automatically adapt alpha beta and radius to fit within the new target.
  34815. * @param target Defines the new target as a Vector or a mesh
  34816. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34817. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34818. */
  34819. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34820. /** @hidden */ private _getViewMatrix(): Matrix;
  34821. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34822. /**
  34823. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34824. * @param meshes Defines the mesh to zoom on
  34825. * @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)
  34826. */
  34827. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34828. /**
  34829. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34830. * The target will be changed but the radius
  34831. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34832. * @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)
  34833. */
  34834. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34835. min: Vector3;
  34836. max: Vector3;
  34837. distance: number;
  34838. }, doNotUpdateMaxZ?: boolean): void;
  34839. /**
  34840. * @override
  34841. * Override Camera.createRigCamera
  34842. */
  34843. createRigCamera(name: string, cameraIndex: number): Camera;
  34844. /**
  34845. * @hidden
  34846. * @override
  34847. * Override Camera._updateRigCameras
  34848. */ private _updateRigCameras(): void;
  34849. /**
  34850. * Destroy the camera and release the current resources hold by it.
  34851. */
  34852. dispose(): void;
  34853. /**
  34854. * Gets the current object class name.
  34855. * @return the class name
  34856. */
  34857. getClassName(): string;
  34858. }
  34859. }
  34860. declare module BABYLON {
  34861. /**
  34862. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34864. */
  34865. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34866. /**
  34867. * Gets the name of the behavior.
  34868. */
  34869. readonly name: string;
  34870. private _zoomStopsAnimation;
  34871. private _idleRotationSpeed;
  34872. private _idleRotationWaitTime;
  34873. private _idleRotationSpinupTime;
  34874. /**
  34875. * Sets the flag that indicates if user zooming should stop animation.
  34876. */
  34877. /**
  34878. * Gets the flag that indicates if user zooming should stop animation.
  34879. */
  34880. zoomStopsAnimation: boolean;
  34881. /**
  34882. * Sets the default speed at which the camera rotates around the model.
  34883. */
  34884. /**
  34885. * Gets the default speed at which the camera rotates around the model.
  34886. */
  34887. idleRotationSpeed: number;
  34888. /**
  34889. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34890. */
  34891. /**
  34892. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34893. */
  34894. idleRotationWaitTime: number;
  34895. /**
  34896. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34897. */
  34898. /**
  34899. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34900. */
  34901. idleRotationSpinupTime: number;
  34902. /**
  34903. * Gets a value indicating if the camera is currently rotating because of this behavior
  34904. */
  34905. readonly rotationInProgress: boolean;
  34906. private _onPrePointerObservableObserver;
  34907. private _onAfterCheckInputsObserver;
  34908. private _attachedCamera;
  34909. private _isPointerDown;
  34910. private _lastFrameTime;
  34911. private _lastInteractionTime;
  34912. private _cameraRotationSpeed;
  34913. /**
  34914. * Initializes the behavior.
  34915. */
  34916. init(): void;
  34917. /**
  34918. * Attaches the behavior to its arc rotate camera.
  34919. * @param camera Defines the camera to attach the behavior to
  34920. */
  34921. attach(camera: ArcRotateCamera): void;
  34922. /**
  34923. * Detaches the behavior from its current arc rotate camera.
  34924. */
  34925. detach(): void;
  34926. /**
  34927. * Returns true if user is scrolling.
  34928. * @return true if user is scrolling.
  34929. */
  34930. private _userIsZooming;
  34931. private _lastFrameRadius;
  34932. private _shouldAnimationStopForInteraction;
  34933. /**
  34934. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34935. */
  34936. private _applyUserInteraction;
  34937. private _userIsMoving;
  34938. }
  34939. }
  34940. declare module BABYLON {
  34941. /**
  34942. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34943. */
  34944. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34945. private ui;
  34946. /**
  34947. * The name of the behavior
  34948. */
  34949. name: string;
  34950. /**
  34951. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34952. */
  34953. distanceAwayFromFace: number;
  34954. /**
  34955. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34956. */
  34957. distanceAwayFromBottomOfFace: number;
  34958. private _faceVectors;
  34959. private _target;
  34960. private _scene;
  34961. private _onRenderObserver;
  34962. private _tmpMatrix;
  34963. private _tmpVector;
  34964. /**
  34965. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34966. * @param ui The transform node that should be attched to the mesh
  34967. */
  34968. constructor(ui: TransformNode);
  34969. /**
  34970. * Initializes the behavior
  34971. */
  34972. init(): void;
  34973. private _closestFace;
  34974. private _zeroVector;
  34975. private _lookAtTmpMatrix;
  34976. private _lookAtToRef;
  34977. /**
  34978. * Attaches the AttachToBoxBehavior to the passed in mesh
  34979. * @param target The mesh that the specified node will be attached to
  34980. */
  34981. attach(target: Mesh): void;
  34982. /**
  34983. * Detaches the behavior from the mesh
  34984. */
  34985. detach(): void;
  34986. }
  34987. }
  34988. declare module BABYLON {
  34989. /**
  34990. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34991. */
  34992. export class FadeInOutBehavior implements Behavior<Mesh> {
  34993. /**
  34994. * Time in milliseconds to delay before fading in (Default: 0)
  34995. */
  34996. delay: number;
  34997. /**
  34998. * Time in milliseconds for the mesh to fade in (Default: 300)
  34999. */
  35000. fadeInTime: number;
  35001. private _millisecondsPerFrame;
  35002. private _hovered;
  35003. private _hoverValue;
  35004. private _ownerNode;
  35005. /**
  35006. * Instatiates the FadeInOutBehavior
  35007. */
  35008. constructor();
  35009. /**
  35010. * The name of the behavior
  35011. */
  35012. readonly name: string;
  35013. /**
  35014. * Initializes the behavior
  35015. */
  35016. init(): void;
  35017. /**
  35018. * Attaches the fade behavior on the passed in mesh
  35019. * @param ownerNode The mesh that will be faded in/out once attached
  35020. */
  35021. attach(ownerNode: Mesh): void;
  35022. /**
  35023. * Detaches the behavior from the mesh
  35024. */
  35025. detach(): void;
  35026. /**
  35027. * Triggers the mesh to begin fading in or out
  35028. * @param value if the object should fade in or out (true to fade in)
  35029. */
  35030. fadeIn(value: boolean): void;
  35031. private _update;
  35032. private _setAllVisibility;
  35033. }
  35034. }
  35035. declare module BABYLON {
  35036. /**
  35037. * Class containing a set of static utilities functions for managing Pivots
  35038. * @hidden
  35039. */
  35040. export class PivotTools {
  35041. private static _PivotCached;
  35042. private static _OldPivotPoint;
  35043. private static _PivotTranslation;
  35044. private static _PivotTmpVector;
  35045. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35046. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35047. }
  35048. }
  35049. declare module BABYLON {
  35050. /**
  35051. * Class containing static functions to help procedurally build meshes
  35052. */
  35053. export class PlaneBuilder {
  35054. /**
  35055. * Creates a plane mesh
  35056. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35057. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35058. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35060. * * 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
  35061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35062. * @param name defines the name of the mesh
  35063. * @param options defines the options used to create the mesh
  35064. * @param scene defines the hosting scene
  35065. * @returns the plane mesh
  35066. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35067. */
  35068. static CreatePlane(name: string, options: {
  35069. size?: number;
  35070. width?: number;
  35071. height?: number;
  35072. sideOrientation?: number;
  35073. frontUVs?: Vector4;
  35074. backUVs?: Vector4;
  35075. updatable?: boolean;
  35076. sourcePlane?: Plane;
  35077. }, scene?: Nullable<Scene>): Mesh;
  35078. }
  35079. }
  35080. declare module BABYLON {
  35081. /**
  35082. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35083. */
  35084. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35085. private static _AnyMouseID;
  35086. /**
  35087. * Abstract mesh the behavior is set on
  35088. */
  35089. attachedNode: AbstractMesh;
  35090. private _dragPlane;
  35091. private _scene;
  35092. private _pointerObserver;
  35093. private _beforeRenderObserver;
  35094. private static _planeScene;
  35095. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35096. /**
  35097. * 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)
  35098. */
  35099. maxDragAngle: number;
  35100. /**
  35101. * @hidden
  35102. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35103. /**
  35104. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35105. */
  35106. currentDraggingPointerID: number;
  35107. /**
  35108. * The last position where the pointer hit the drag plane in world space
  35109. */
  35110. lastDragPosition: Vector3;
  35111. /**
  35112. * If the behavior is currently in a dragging state
  35113. */
  35114. dragging: boolean;
  35115. /**
  35116. * 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)
  35117. */
  35118. dragDeltaRatio: number;
  35119. /**
  35120. * If the drag plane orientation should be updated during the dragging (Default: true)
  35121. */
  35122. updateDragPlane: boolean;
  35123. private _debugMode;
  35124. private _moving;
  35125. /**
  35126. * Fires each time the attached mesh is dragged with the pointer
  35127. * * delta between last drag position and current drag position in world space
  35128. * * dragDistance along the drag axis
  35129. * * dragPlaneNormal normal of the current drag plane used during the drag
  35130. * * dragPlanePoint in world space where the drag intersects the drag plane
  35131. */
  35132. onDragObservable: Observable<{
  35133. delta: Vector3;
  35134. dragPlanePoint: Vector3;
  35135. dragPlaneNormal: Vector3;
  35136. dragDistance: number;
  35137. pointerId: number;
  35138. }>;
  35139. /**
  35140. * Fires each time a drag begins (eg. mouse down on mesh)
  35141. */
  35142. onDragStartObservable: Observable<{
  35143. dragPlanePoint: Vector3;
  35144. pointerId: number;
  35145. }>;
  35146. /**
  35147. * Fires each time a drag ends (eg. mouse release after drag)
  35148. */
  35149. onDragEndObservable: Observable<{
  35150. dragPlanePoint: Vector3;
  35151. pointerId: number;
  35152. }>;
  35153. /**
  35154. * If the attached mesh should be moved when dragged
  35155. */
  35156. moveAttached: boolean;
  35157. /**
  35158. * If the drag behavior will react to drag events (Default: true)
  35159. */
  35160. enabled: boolean;
  35161. /**
  35162. * If camera controls should be detached during the drag
  35163. */
  35164. detachCameraControls: boolean;
  35165. /**
  35166. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35167. */
  35168. useObjectOrienationForDragging: boolean;
  35169. private _options;
  35170. /**
  35171. * Creates a pointer drag behavior that can be attached to a mesh
  35172. * @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)
  35173. */
  35174. constructor(options?: {
  35175. dragAxis?: Vector3;
  35176. dragPlaneNormal?: Vector3;
  35177. });
  35178. /**
  35179. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35180. */
  35181. validateDrag: (targetPosition: Vector3) => boolean;
  35182. /**
  35183. * The name of the behavior
  35184. */
  35185. readonly name: string;
  35186. /**
  35187. * Initializes the behavior
  35188. */
  35189. init(): void;
  35190. private _tmpVector;
  35191. private _alternatePickedPoint;
  35192. private _worldDragAxis;
  35193. private _targetPosition;
  35194. private _attachedElement;
  35195. /**
  35196. * Attaches the drag behavior the passed in mesh
  35197. * @param ownerNode The mesh that will be dragged around once attached
  35198. */
  35199. attach(ownerNode: AbstractMesh): void;
  35200. /**
  35201. * Force relase the drag action by code.
  35202. */
  35203. releaseDrag(): void;
  35204. private _startDragRay;
  35205. private _lastPointerRay;
  35206. /**
  35207. * Simulates the start of a pointer drag event on the behavior
  35208. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35209. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35210. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35211. */
  35212. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35213. private _startDrag;
  35214. private _dragDelta;
  35215. private _moveDrag;
  35216. private _pickWithRayOnDragPlane;
  35217. private _pointA;
  35218. private _pointB;
  35219. private _pointC;
  35220. private _lineA;
  35221. private _lineB;
  35222. private _localAxis;
  35223. private _lookAt;
  35224. private _updateDragPlanePosition;
  35225. /**
  35226. * Detaches the behavior from the mesh
  35227. */
  35228. detach(): void;
  35229. }
  35230. }
  35231. declare module BABYLON {
  35232. /**
  35233. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35234. */
  35235. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35236. private _dragBehaviorA;
  35237. private _dragBehaviorB;
  35238. private _startDistance;
  35239. private _initialScale;
  35240. private _targetScale;
  35241. private _ownerNode;
  35242. private _sceneRenderObserver;
  35243. /**
  35244. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35245. */
  35246. constructor();
  35247. /**
  35248. * The name of the behavior
  35249. */
  35250. readonly name: string;
  35251. /**
  35252. * Initializes the behavior
  35253. */
  35254. init(): void;
  35255. private _getCurrentDistance;
  35256. /**
  35257. * Attaches the scale behavior the passed in mesh
  35258. * @param ownerNode The mesh that will be scaled around once attached
  35259. */
  35260. attach(ownerNode: Mesh): void;
  35261. /**
  35262. * Detaches the behavior from the mesh
  35263. */
  35264. detach(): void;
  35265. }
  35266. }
  35267. declare module BABYLON {
  35268. /**
  35269. * 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
  35270. */
  35271. export class SixDofDragBehavior implements Behavior<Mesh> {
  35272. private static _virtualScene;
  35273. private _ownerNode;
  35274. private _sceneRenderObserver;
  35275. private _scene;
  35276. private _targetPosition;
  35277. private _virtualOriginMesh;
  35278. private _virtualDragMesh;
  35279. private _pointerObserver;
  35280. private _moving;
  35281. private _startingOrientation;
  35282. /**
  35283. * 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)
  35284. */
  35285. private zDragFactor;
  35286. /**
  35287. * If the object should rotate to face the drag origin
  35288. */
  35289. rotateDraggedObject: boolean;
  35290. /**
  35291. * If the behavior is currently in a dragging state
  35292. */
  35293. dragging: boolean;
  35294. /**
  35295. * 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)
  35296. */
  35297. dragDeltaRatio: number;
  35298. /**
  35299. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35300. */
  35301. currentDraggingPointerID: number;
  35302. /**
  35303. * If camera controls should be detached during the drag
  35304. */
  35305. detachCameraControls: boolean;
  35306. /**
  35307. * Fires each time a drag starts
  35308. */
  35309. onDragStartObservable: Observable<{}>;
  35310. /**
  35311. * Fires each time a drag ends (eg. mouse release after drag)
  35312. */
  35313. onDragEndObservable: Observable<{}>;
  35314. /**
  35315. * 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
  35316. */
  35317. constructor();
  35318. /**
  35319. * The name of the behavior
  35320. */
  35321. readonly name: string;
  35322. /**
  35323. * Initializes the behavior
  35324. */
  35325. init(): void;
  35326. /**
  35327. * Attaches the scale behavior the passed in mesh
  35328. * @param ownerNode The mesh that will be scaled around once attached
  35329. */
  35330. attach(ownerNode: Mesh): void;
  35331. /**
  35332. * Detaches the behavior from the mesh
  35333. */
  35334. detach(): void;
  35335. }
  35336. }
  35337. declare module BABYLON {
  35338. /**
  35339. * Class used to apply inverse kinematics to bones
  35340. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35341. */
  35342. export class BoneIKController {
  35343. private static _tmpVecs;
  35344. private static _tmpQuat;
  35345. private static _tmpMats;
  35346. /**
  35347. * Gets or sets the target mesh
  35348. */
  35349. targetMesh: AbstractMesh;
  35350. /** Gets or sets the mesh used as pole */
  35351. poleTargetMesh: AbstractMesh;
  35352. /**
  35353. * Gets or sets the bone used as pole
  35354. */
  35355. poleTargetBone: Nullable<Bone>;
  35356. /**
  35357. * Gets or sets the target position
  35358. */
  35359. targetPosition: Vector3;
  35360. /**
  35361. * Gets or sets the pole target position
  35362. */
  35363. poleTargetPosition: Vector3;
  35364. /**
  35365. * Gets or sets the pole target local offset
  35366. */
  35367. poleTargetLocalOffset: Vector3;
  35368. /**
  35369. * Gets or sets the pole angle
  35370. */
  35371. poleAngle: number;
  35372. /**
  35373. * Gets or sets the mesh associated with the controller
  35374. */
  35375. mesh: AbstractMesh;
  35376. /**
  35377. * 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)
  35378. */
  35379. slerpAmount: number;
  35380. private _bone1Quat;
  35381. private _bone1Mat;
  35382. private _bone2Ang;
  35383. private _bone1;
  35384. private _bone2;
  35385. private _bone1Length;
  35386. private _bone2Length;
  35387. private _maxAngle;
  35388. private _maxReach;
  35389. private _rightHandedSystem;
  35390. private _bendAxis;
  35391. private _slerping;
  35392. private _adjustRoll;
  35393. /**
  35394. * Gets or sets maximum allowed angle
  35395. */
  35396. maxAngle: number;
  35397. /**
  35398. * Creates a new BoneIKController
  35399. * @param mesh defines the mesh to control
  35400. * @param bone defines the bone to control
  35401. * @param options defines options to set up the controller
  35402. */
  35403. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35404. targetMesh?: AbstractMesh;
  35405. poleTargetMesh?: AbstractMesh;
  35406. poleTargetBone?: Bone;
  35407. poleTargetLocalOffset?: Vector3;
  35408. poleAngle?: number;
  35409. bendAxis?: Vector3;
  35410. maxAngle?: number;
  35411. slerpAmount?: number;
  35412. });
  35413. private _setMaxAngle;
  35414. /**
  35415. * Force the controller to update the bones
  35416. */
  35417. update(): void;
  35418. }
  35419. }
  35420. declare module BABYLON {
  35421. /**
  35422. * Class used to make a bone look toward a point in space
  35423. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35424. */
  35425. export class BoneLookController {
  35426. private static _tmpVecs;
  35427. private static _tmpQuat;
  35428. private static _tmpMats;
  35429. /**
  35430. * The target Vector3 that the bone will look at
  35431. */
  35432. target: Vector3;
  35433. /**
  35434. * The mesh that the bone is attached to
  35435. */
  35436. mesh: AbstractMesh;
  35437. /**
  35438. * The bone that will be looking to the target
  35439. */
  35440. bone: Bone;
  35441. /**
  35442. * The up axis of the coordinate system that is used when the bone is rotated
  35443. */
  35444. upAxis: Vector3;
  35445. /**
  35446. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35447. */
  35448. upAxisSpace: Space;
  35449. /**
  35450. * Used to make an adjustment to the yaw of the bone
  35451. */
  35452. adjustYaw: number;
  35453. /**
  35454. * Used to make an adjustment to the pitch of the bone
  35455. */
  35456. adjustPitch: number;
  35457. /**
  35458. * Used to make an adjustment to the roll of the bone
  35459. */
  35460. adjustRoll: number;
  35461. /**
  35462. * 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)
  35463. */
  35464. slerpAmount: number;
  35465. private _minYaw;
  35466. private _maxYaw;
  35467. private _minPitch;
  35468. private _maxPitch;
  35469. private _minYawSin;
  35470. private _minYawCos;
  35471. private _maxYawSin;
  35472. private _maxYawCos;
  35473. private _midYawConstraint;
  35474. private _minPitchTan;
  35475. private _maxPitchTan;
  35476. private _boneQuat;
  35477. private _slerping;
  35478. private _transformYawPitch;
  35479. private _transformYawPitchInv;
  35480. private _firstFrameSkipped;
  35481. private _yawRange;
  35482. private _fowardAxis;
  35483. /**
  35484. * Gets or sets the minimum yaw angle that the bone can look to
  35485. */
  35486. minYaw: number;
  35487. /**
  35488. * Gets or sets the maximum yaw angle that the bone can look to
  35489. */
  35490. maxYaw: number;
  35491. /**
  35492. * Gets or sets the minimum pitch angle that the bone can look to
  35493. */
  35494. minPitch: number;
  35495. /**
  35496. * Gets or sets the maximum pitch angle that the bone can look to
  35497. */
  35498. maxPitch: number;
  35499. /**
  35500. * Create a BoneLookController
  35501. * @param mesh the mesh that the bone belongs to
  35502. * @param bone the bone that will be looking to the target
  35503. * @param target the target Vector3 to look at
  35504. * @param options optional settings:
  35505. * * maxYaw: the maximum angle the bone will yaw to
  35506. * * minYaw: the minimum angle the bone will yaw to
  35507. * * maxPitch: the maximum angle the bone will pitch to
  35508. * * minPitch: the minimum angle the bone will yaw to
  35509. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35510. * * upAxis: the up axis of the coordinate system
  35511. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35512. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35513. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35514. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35515. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35516. * * adjustRoll: used to make an adjustment to the roll of the bone
  35517. **/
  35518. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35519. maxYaw?: number;
  35520. minYaw?: number;
  35521. maxPitch?: number;
  35522. minPitch?: number;
  35523. slerpAmount?: number;
  35524. upAxis?: Vector3;
  35525. upAxisSpace?: Space;
  35526. yawAxis?: Vector3;
  35527. pitchAxis?: Vector3;
  35528. adjustYaw?: number;
  35529. adjustPitch?: number;
  35530. adjustRoll?: number;
  35531. });
  35532. /**
  35533. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35534. */
  35535. update(): void;
  35536. private _getAngleDiff;
  35537. private _getAngleBetween;
  35538. private _isAngleBetween;
  35539. }
  35540. }
  35541. declare module BABYLON {
  35542. /**
  35543. * Manage the gamepad inputs to control an arc rotate camera.
  35544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35545. */
  35546. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35547. /**
  35548. * Defines the camera the input is attached to.
  35549. */
  35550. camera: ArcRotateCamera;
  35551. /**
  35552. * Defines the gamepad the input is gathering event from.
  35553. */
  35554. gamepad: Nullable<Gamepad>;
  35555. /**
  35556. * Defines the gamepad rotation sensiblity.
  35557. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35558. */
  35559. gamepadRotationSensibility: number;
  35560. /**
  35561. * Defines the gamepad move sensiblity.
  35562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35563. */
  35564. gamepadMoveSensibility: number;
  35565. private _onGamepadConnectedObserver;
  35566. private _onGamepadDisconnectedObserver;
  35567. /**
  35568. * Attach the input controls to a specific dom element to get the input from.
  35569. * @param element Defines the element the controls should be listened from
  35570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35571. */
  35572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35573. /**
  35574. * Detach the current controls from the specified dom element.
  35575. * @param element Defines the element to stop listening the inputs from
  35576. */
  35577. detachControl(element: Nullable<HTMLElement>): void;
  35578. /**
  35579. * Update the current camera state depending on the inputs that have been used this frame.
  35580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35581. */
  35582. checkInputs(): void;
  35583. /**
  35584. * Gets the class name of the current intput.
  35585. * @returns the class name
  35586. */
  35587. getClassName(): string;
  35588. /**
  35589. * Get the friendly name associated with the input class.
  35590. * @returns the input friendly name
  35591. */
  35592. getSimpleName(): string;
  35593. }
  35594. }
  35595. declare module BABYLON {
  35596. interface ArcRotateCameraInputsManager {
  35597. /**
  35598. * Add orientation input support to the input manager.
  35599. * @returns the current input manager
  35600. */
  35601. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35602. }
  35603. /**
  35604. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35605. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35606. */
  35607. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35608. /**
  35609. * Defines the camera the input is attached to.
  35610. */
  35611. camera: ArcRotateCamera;
  35612. /**
  35613. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35614. */
  35615. alphaCorrection: number;
  35616. /**
  35617. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35618. */
  35619. gammaCorrection: number;
  35620. private _alpha;
  35621. private _gamma;
  35622. private _dirty;
  35623. private _deviceOrientationHandler;
  35624. /**
  35625. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35626. */
  35627. constructor();
  35628. /**
  35629. * Attach the input controls to a specific dom element to get the input from.
  35630. * @param element Defines the element the controls should be listened from
  35631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35632. */
  35633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35634. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35635. /**
  35636. * Update the current camera state depending on the inputs that have been used this frame.
  35637. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35638. */
  35639. checkInputs(): void;
  35640. /**
  35641. * Detach the current controls from the specified dom element.
  35642. * @param element Defines the element to stop listening the inputs from
  35643. */
  35644. detachControl(element: Nullable<HTMLElement>): void;
  35645. /**
  35646. * Gets the class name of the current intput.
  35647. * @returns the class name
  35648. */
  35649. getClassName(): string;
  35650. /**
  35651. * Get the friendly name associated with the input class.
  35652. * @returns the input friendly name
  35653. */
  35654. getSimpleName(): string;
  35655. }
  35656. }
  35657. declare module BABYLON {
  35658. /**
  35659. * Listen to mouse events to control the camera.
  35660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35661. */
  35662. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35663. /**
  35664. * Defines the camera the input is attached to.
  35665. */
  35666. camera: FlyCamera;
  35667. /**
  35668. * Defines if touch is enabled. (Default is true.)
  35669. */
  35670. touchEnabled: boolean;
  35671. /**
  35672. * Defines the buttons associated with the input to handle camera rotation.
  35673. */
  35674. buttons: number[];
  35675. /**
  35676. * Assign buttons for Yaw control.
  35677. */
  35678. buttonsYaw: number[];
  35679. /**
  35680. * Assign buttons for Pitch control.
  35681. */
  35682. buttonsPitch: number[];
  35683. /**
  35684. * Assign buttons for Roll control.
  35685. */
  35686. buttonsRoll: number[];
  35687. /**
  35688. * Detect if any button is being pressed while mouse is moved.
  35689. * -1 = Mouse locked.
  35690. * 0 = Left button.
  35691. * 1 = Middle Button.
  35692. * 2 = Right Button.
  35693. */
  35694. activeButton: number;
  35695. /**
  35696. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35697. * Higher values reduce its sensitivity.
  35698. */
  35699. angularSensibility: number;
  35700. private _mousemoveCallback;
  35701. private _observer;
  35702. private _rollObserver;
  35703. private previousPosition;
  35704. private noPreventDefault;
  35705. private element;
  35706. /**
  35707. * Listen to mouse events to control the camera.
  35708. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35710. */
  35711. constructor(touchEnabled?: boolean);
  35712. /**
  35713. * Attach the mouse control to the HTML DOM element.
  35714. * @param element Defines the element that listens to the input events.
  35715. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35716. */
  35717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35718. /**
  35719. * Detach the current controls from the specified dom element.
  35720. * @param element Defines the element to stop listening the inputs from
  35721. */
  35722. detachControl(element: Nullable<HTMLElement>): void;
  35723. /**
  35724. * Gets the class name of the current input.
  35725. * @returns the class name.
  35726. */
  35727. getClassName(): string;
  35728. /**
  35729. * Get the friendly name associated with the input class.
  35730. * @returns the input's friendly name.
  35731. */
  35732. getSimpleName(): string;
  35733. private _pointerInput;
  35734. private _onMouseMove;
  35735. /**
  35736. * Rotate camera by mouse offset.
  35737. */
  35738. private rotateCamera;
  35739. }
  35740. }
  35741. declare module BABYLON {
  35742. /**
  35743. * Default Inputs manager for the FlyCamera.
  35744. * It groups all the default supported inputs for ease of use.
  35745. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35746. */
  35747. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35748. /**
  35749. * Instantiates a new FlyCameraInputsManager.
  35750. * @param camera Defines the camera the inputs belong to.
  35751. */
  35752. constructor(camera: FlyCamera);
  35753. /**
  35754. * Add keyboard input support to the input manager.
  35755. * @returns the new FlyCameraKeyboardMoveInput().
  35756. */
  35757. addKeyboard(): FlyCameraInputsManager;
  35758. /**
  35759. * Add mouse input support to the input manager.
  35760. * @param touchEnabled Enable touch screen support.
  35761. * @returns the new FlyCameraMouseInput().
  35762. */
  35763. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35764. }
  35765. }
  35766. declare module BABYLON {
  35767. /**
  35768. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35769. * such as in a 3D Space Shooter or a Flight Simulator.
  35770. */
  35771. export class FlyCamera extends TargetCamera {
  35772. /**
  35773. * Define the collision ellipsoid of the camera.
  35774. * This is helpful for simulating a camera body, like a player's body.
  35775. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35776. */
  35777. ellipsoid: Vector3;
  35778. /**
  35779. * Define an offset for the position of the ellipsoid around the camera.
  35780. * This can be helpful if the camera is attached away from the player's body center,
  35781. * such as at its head.
  35782. */
  35783. ellipsoidOffset: Vector3;
  35784. /**
  35785. * Enable or disable collisions of the camera with the rest of the scene objects.
  35786. */
  35787. checkCollisions: boolean;
  35788. /**
  35789. * Enable or disable gravity on the camera.
  35790. */
  35791. applyGravity: boolean;
  35792. /**
  35793. * Define the current direction the camera is moving to.
  35794. */
  35795. cameraDirection: Vector3;
  35796. /**
  35797. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35798. * This overrides and empties cameraRotation.
  35799. */
  35800. rotationQuaternion: Quaternion;
  35801. /**
  35802. * Track Roll to maintain the wanted Rolling when looking around.
  35803. */ private _trackRoll: number;
  35804. /**
  35805. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35806. */
  35807. rollCorrect: number;
  35808. /**
  35809. * Mimic a banked turn, Rolling the camera when Yawing.
  35810. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35811. */
  35812. bankedTurn: boolean;
  35813. /**
  35814. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35815. */
  35816. bankedTurnLimit: number;
  35817. /**
  35818. * Value of 0 disables the banked Roll.
  35819. * Value of 1 is equal to the Yaw angle in radians.
  35820. */
  35821. bankedTurnMultiplier: number;
  35822. /**
  35823. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35824. */
  35825. inputs: FlyCameraInputsManager;
  35826. /**
  35827. * Gets the input sensibility for mouse input.
  35828. * Higher values reduce sensitivity.
  35829. */
  35830. /**
  35831. * Sets the input sensibility for a mouse input.
  35832. * Higher values reduce sensitivity.
  35833. */
  35834. angularSensibility: number;
  35835. /**
  35836. * Get the keys for camera movement forward.
  35837. */
  35838. /**
  35839. * Set the keys for camera movement forward.
  35840. */
  35841. keysForward: number[];
  35842. /**
  35843. * Get the keys for camera movement backward.
  35844. */
  35845. keysBackward: number[];
  35846. /**
  35847. * Get the keys for camera movement up.
  35848. */
  35849. /**
  35850. * Set the keys for camera movement up.
  35851. */
  35852. keysUp: number[];
  35853. /**
  35854. * Get the keys for camera movement down.
  35855. */
  35856. /**
  35857. * Set the keys for camera movement down.
  35858. */
  35859. keysDown: number[];
  35860. /**
  35861. * Get the keys for camera movement left.
  35862. */
  35863. /**
  35864. * Set the keys for camera movement left.
  35865. */
  35866. keysLeft: number[];
  35867. /**
  35868. * Set the keys for camera movement right.
  35869. */
  35870. /**
  35871. * Set the keys for camera movement right.
  35872. */
  35873. keysRight: number[];
  35874. /**
  35875. * Event raised when the camera collides with a mesh in the scene.
  35876. */
  35877. onCollide: (collidedMesh: AbstractMesh) => void;
  35878. private _collider;
  35879. private _needMoveForGravity;
  35880. private _oldPosition;
  35881. private _diffPosition;
  35882. private _newPosition;
  35883. /** @hidden */ private _localDirection: Vector3;
  35884. /** @hidden */ private _transformedDirection: Vector3;
  35885. /**
  35886. * Instantiates a FlyCamera.
  35887. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35888. * such as in a 3D Space Shooter or a Flight Simulator.
  35889. * @param name Define the name of the camera in the scene.
  35890. * @param position Define the starting position of the camera in the scene.
  35891. * @param scene Define the scene the camera belongs to.
  35892. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35893. */
  35894. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35895. /**
  35896. * Attach a control to the HTML DOM element.
  35897. * @param element Defines the element that listens to the input events.
  35898. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35899. */
  35900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35901. /**
  35902. * Detach a control from the HTML DOM element.
  35903. * The camera will stop reacting to that input.
  35904. * @param element Defines the element that listens to the input events.
  35905. */
  35906. detachControl(element: HTMLElement): void;
  35907. private _collisionMask;
  35908. /**
  35909. * Get the mask that the camera ignores in collision events.
  35910. */
  35911. /**
  35912. * Set the mask that the camera ignores in collision events.
  35913. */
  35914. collisionMask: number;
  35915. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  35916. /** @hidden */
  35917. private _onCollisionPositionChange;
  35918. /** @hidden */ private _checkInputs(): void;
  35919. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  35920. /** @hidden */ private _updatePosition(): void;
  35921. /**
  35922. * Restore the Roll to its target value at the rate specified.
  35923. * @param rate - Higher means slower restoring.
  35924. * @hidden
  35925. */
  35926. restoreRoll(rate: number): void;
  35927. /**
  35928. * Destroy the camera and release the current resources held by it.
  35929. */
  35930. dispose(): void;
  35931. /**
  35932. * Get the current object class name.
  35933. * @returns the class name.
  35934. */
  35935. getClassName(): string;
  35936. }
  35937. }
  35938. declare module BABYLON {
  35939. /**
  35940. * Listen to keyboard events to control the camera.
  35941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35942. */
  35943. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35944. /**
  35945. * Defines the camera the input is attached to.
  35946. */
  35947. camera: FlyCamera;
  35948. /**
  35949. * The list of keyboard keys used to control the forward move of the camera.
  35950. */
  35951. keysForward: number[];
  35952. /**
  35953. * The list of keyboard keys used to control the backward move of the camera.
  35954. */
  35955. keysBackward: number[];
  35956. /**
  35957. * The list of keyboard keys used to control the forward move of the camera.
  35958. */
  35959. keysUp: number[];
  35960. /**
  35961. * The list of keyboard keys used to control the backward move of the camera.
  35962. */
  35963. keysDown: number[];
  35964. /**
  35965. * The list of keyboard keys used to control the right strafe move of the camera.
  35966. */
  35967. keysRight: number[];
  35968. /**
  35969. * The list of keyboard keys used to control the left strafe move of the camera.
  35970. */
  35971. keysLeft: number[];
  35972. private _keys;
  35973. private _onCanvasBlurObserver;
  35974. private _onKeyboardObserver;
  35975. private _engine;
  35976. private _scene;
  35977. /**
  35978. * Attach the input controls to a specific dom element to get the input from.
  35979. * @param element Defines the element the controls should be listened from
  35980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35981. */
  35982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35983. /**
  35984. * Detach the current controls from the specified dom element.
  35985. * @param element Defines the element to stop listening the inputs from
  35986. */
  35987. detachControl(element: Nullable<HTMLElement>): void;
  35988. /**
  35989. * Gets the class name of the current intput.
  35990. * @returns the class name
  35991. */
  35992. getClassName(): string;
  35993. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  35994. /**
  35995. * Get the friendly name associated with the input class.
  35996. * @returns the input friendly name
  35997. */
  35998. getSimpleName(): string;
  35999. /**
  36000. * Update the current camera state depending on the inputs that have been used this frame.
  36001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36002. */
  36003. checkInputs(): void;
  36004. }
  36005. }
  36006. declare module BABYLON {
  36007. /**
  36008. * Manage the mouse wheel inputs to control a follow camera.
  36009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36010. */
  36011. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36012. /**
  36013. * Defines the camera the input is attached to.
  36014. */
  36015. camera: FollowCamera;
  36016. /**
  36017. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36018. */
  36019. axisControlRadius: boolean;
  36020. /**
  36021. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36022. */
  36023. axisControlHeight: boolean;
  36024. /**
  36025. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36026. */
  36027. axisControlRotation: boolean;
  36028. /**
  36029. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36030. * relation to mouseWheel events.
  36031. */
  36032. wheelPrecision: number;
  36033. /**
  36034. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36035. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36036. */
  36037. wheelDeltaPercentage: number;
  36038. private _wheel;
  36039. private _observer;
  36040. /**
  36041. * Attach the input controls to a specific dom element to get the input from.
  36042. * @param element Defines the element the controls should be listened from
  36043. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36044. */
  36045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36046. /**
  36047. * Detach the current controls from the specified dom element.
  36048. * @param element Defines the element to stop listening the inputs from
  36049. */
  36050. detachControl(element: Nullable<HTMLElement>): void;
  36051. /**
  36052. * Gets the class name of the current intput.
  36053. * @returns the class name
  36054. */
  36055. getClassName(): string;
  36056. /**
  36057. * Get the friendly name associated with the input class.
  36058. * @returns the input friendly name
  36059. */
  36060. getSimpleName(): string;
  36061. }
  36062. }
  36063. declare module BABYLON {
  36064. /**
  36065. * Manage the pointers inputs to control an follow camera.
  36066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36067. */
  36068. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36069. /**
  36070. * Defines the camera the input is attached to.
  36071. */
  36072. camera: FollowCamera;
  36073. /**
  36074. * Gets the class name of the current input.
  36075. * @returns the class name
  36076. */
  36077. getClassName(): string;
  36078. /**
  36079. * Defines the pointer angular sensibility along the X axis or how fast is
  36080. * the camera rotating.
  36081. * A negative number will reverse the axis direction.
  36082. */
  36083. angularSensibilityX: number;
  36084. /**
  36085. * Defines the pointer angular sensibility along the Y axis or how fast is
  36086. * the camera rotating.
  36087. * A negative number will reverse the axis direction.
  36088. */
  36089. angularSensibilityY: number;
  36090. /**
  36091. * Defines the pointer pinch precision or how fast is the camera zooming.
  36092. * A negative number will reverse the axis direction.
  36093. */
  36094. pinchPrecision: number;
  36095. /**
  36096. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36097. * from 0.
  36098. * It defines the percentage of current camera.radius to use as delta when
  36099. * pinch zoom is used.
  36100. */
  36101. pinchDeltaPercentage: number;
  36102. /**
  36103. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36104. */
  36105. axisXControlRadius: boolean;
  36106. /**
  36107. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36108. */
  36109. axisXControlHeight: boolean;
  36110. /**
  36111. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36112. */
  36113. axisXControlRotation: boolean;
  36114. /**
  36115. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36116. */
  36117. axisYControlRadius: boolean;
  36118. /**
  36119. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36120. */
  36121. axisYControlHeight: boolean;
  36122. /**
  36123. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36124. */
  36125. axisYControlRotation: boolean;
  36126. /**
  36127. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36128. */
  36129. axisPinchControlRadius: boolean;
  36130. /**
  36131. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36132. */
  36133. axisPinchControlHeight: boolean;
  36134. /**
  36135. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36136. */
  36137. axisPinchControlRotation: boolean;
  36138. /**
  36139. * Log error messages if basic misconfiguration has occurred.
  36140. */
  36141. warningEnable: boolean;
  36142. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36143. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36144. private _warningCounter;
  36145. private _warning;
  36146. }
  36147. }
  36148. declare module BABYLON {
  36149. /**
  36150. * Default Inputs manager for the FollowCamera.
  36151. * It groups all the default supported inputs for ease of use.
  36152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36153. */
  36154. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36155. /**
  36156. * Instantiates a new FollowCameraInputsManager.
  36157. * @param camera Defines the camera the inputs belong to
  36158. */
  36159. constructor(camera: FollowCamera);
  36160. /**
  36161. * Add keyboard input support to the input manager.
  36162. * @returns the current input manager
  36163. */
  36164. addKeyboard(): FollowCameraInputsManager;
  36165. /**
  36166. * Add mouse wheel input support to the input manager.
  36167. * @returns the current input manager
  36168. */
  36169. addMouseWheel(): FollowCameraInputsManager;
  36170. /**
  36171. * Add pointers input support to the input manager.
  36172. * @returns the current input manager
  36173. */
  36174. addPointers(): FollowCameraInputsManager;
  36175. /**
  36176. * Add orientation input support to the input manager.
  36177. * @returns the current input manager
  36178. */
  36179. addVRDeviceOrientation(): FollowCameraInputsManager;
  36180. }
  36181. }
  36182. declare module BABYLON {
  36183. /**
  36184. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36185. * an arc rotate version arcFollowCamera are available.
  36186. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36187. */
  36188. export class FollowCamera extends TargetCamera {
  36189. /**
  36190. * Distance the follow camera should follow an object at
  36191. */
  36192. radius: number;
  36193. /**
  36194. * Minimum allowed distance of the camera to the axis of rotation
  36195. * (The camera can not get closer).
  36196. * This can help limiting how the Camera is able to move in the scene.
  36197. */
  36198. lowerRadiusLimit: Nullable<number>;
  36199. /**
  36200. * Maximum allowed distance of the camera to the axis of rotation
  36201. * (The camera can not get further).
  36202. * This can help limiting how the Camera is able to move in the scene.
  36203. */
  36204. upperRadiusLimit: Nullable<number>;
  36205. /**
  36206. * Define a rotation offset between the camera and the object it follows
  36207. */
  36208. rotationOffset: number;
  36209. /**
  36210. * Minimum allowed angle to camera position relative to target object.
  36211. * This can help limiting how the Camera is able to move in the scene.
  36212. */
  36213. lowerRotationOffsetLimit: Nullable<number>;
  36214. /**
  36215. * Maximum allowed angle to camera position relative to target object.
  36216. * This can help limiting how the Camera is able to move in the scene.
  36217. */
  36218. upperRotationOffsetLimit: Nullable<number>;
  36219. /**
  36220. * Define a height offset between the camera and the object it follows.
  36221. * It can help following an object from the top (like a car chaing a plane)
  36222. */
  36223. heightOffset: number;
  36224. /**
  36225. * Minimum allowed height of camera position relative to target object.
  36226. * This can help limiting how the Camera is able to move in the scene.
  36227. */
  36228. lowerHeightOffsetLimit: Nullable<number>;
  36229. /**
  36230. * Maximum allowed height of camera position relative to target object.
  36231. * This can help limiting how the Camera is able to move in the scene.
  36232. */
  36233. upperHeightOffsetLimit: Nullable<number>;
  36234. /**
  36235. * Define how fast the camera can accelerate to follow it s target.
  36236. */
  36237. cameraAcceleration: number;
  36238. /**
  36239. * Define the speed limit of the camera following an object.
  36240. */
  36241. maxCameraSpeed: number;
  36242. /**
  36243. * Define the target of the camera.
  36244. */
  36245. lockedTarget: Nullable<AbstractMesh>;
  36246. /**
  36247. * Defines the input associated with the camera.
  36248. */
  36249. inputs: FollowCameraInputsManager;
  36250. /**
  36251. * Instantiates the follow camera.
  36252. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36253. * @param name Define the name of the camera in the scene
  36254. * @param position Define the position of the camera
  36255. * @param scene Define the scene the camera belong to
  36256. * @param lockedTarget Define the target of the camera
  36257. */
  36258. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36259. private _follow;
  36260. /**
  36261. * Attached controls to the current camera.
  36262. * @param element Defines the element the controls should be listened from
  36263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36264. */
  36265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36266. /**
  36267. * Detach the current controls from the camera.
  36268. * The camera will stop reacting to inputs.
  36269. * @param element Defines the element to stop listening the inputs from
  36270. */
  36271. detachControl(element: HTMLElement): void;
  36272. /** @hidden */ private _checkInputs(): void;
  36273. private _checkLimits;
  36274. /**
  36275. * Gets the camera class name.
  36276. * @returns the class name
  36277. */
  36278. getClassName(): string;
  36279. }
  36280. /**
  36281. * Arc Rotate version of the follow camera.
  36282. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36283. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36284. */
  36285. export class ArcFollowCamera extends TargetCamera {
  36286. /** The longitudinal angle of the camera */
  36287. alpha: number;
  36288. /** The latitudinal angle of the camera */
  36289. beta: number;
  36290. /** The radius of the camera from its target */
  36291. radius: number;
  36292. /** Define the camera target (the messh it should follow) */
  36293. target: Nullable<AbstractMesh>;
  36294. private _cartesianCoordinates;
  36295. /**
  36296. * Instantiates a new ArcFollowCamera
  36297. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36298. * @param name Define the name of the camera
  36299. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36300. * @param beta Define the rotation angle of the camera around the elevation axis
  36301. * @param radius Define the radius of the camera from its target point
  36302. * @param target Define the target of the camera
  36303. * @param scene Define the scene the camera belongs to
  36304. */
  36305. constructor(name: string,
  36306. /** The longitudinal angle of the camera */
  36307. alpha: number,
  36308. /** The latitudinal angle of the camera */
  36309. beta: number,
  36310. /** The radius of the camera from its target */
  36311. radius: number,
  36312. /** Define the camera target (the messh it should follow) */
  36313. target: Nullable<AbstractMesh>, scene: Scene);
  36314. private _follow;
  36315. /** @hidden */ private _checkInputs(): void;
  36316. /**
  36317. * Returns the class name of the object.
  36318. * It is mostly used internally for serialization purposes.
  36319. */
  36320. getClassName(): string;
  36321. }
  36322. }
  36323. declare module BABYLON {
  36324. /**
  36325. * Manage the keyboard inputs to control the movement of a follow camera.
  36326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36327. */
  36328. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36329. /**
  36330. * Defines the camera the input is attached to.
  36331. */
  36332. camera: FollowCamera;
  36333. /**
  36334. * Defines the list of key codes associated with the up action (increase heightOffset)
  36335. */
  36336. keysHeightOffsetIncr: number[];
  36337. /**
  36338. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36339. */
  36340. keysHeightOffsetDecr: number[];
  36341. /**
  36342. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36343. */
  36344. keysHeightOffsetModifierAlt: boolean;
  36345. /**
  36346. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36347. */
  36348. keysHeightOffsetModifierCtrl: boolean;
  36349. /**
  36350. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36351. */
  36352. keysHeightOffsetModifierShift: boolean;
  36353. /**
  36354. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36355. */
  36356. keysRotationOffsetIncr: number[];
  36357. /**
  36358. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36359. */
  36360. keysRotationOffsetDecr: number[];
  36361. /**
  36362. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36363. */
  36364. keysRotationOffsetModifierAlt: boolean;
  36365. /**
  36366. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36367. */
  36368. keysRotationOffsetModifierCtrl: boolean;
  36369. /**
  36370. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36371. */
  36372. keysRotationOffsetModifierShift: boolean;
  36373. /**
  36374. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36375. */
  36376. keysRadiusIncr: number[];
  36377. /**
  36378. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36379. */
  36380. keysRadiusDecr: number[];
  36381. /**
  36382. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36383. */
  36384. keysRadiusModifierAlt: boolean;
  36385. /**
  36386. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36387. */
  36388. keysRadiusModifierCtrl: boolean;
  36389. /**
  36390. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36391. */
  36392. keysRadiusModifierShift: boolean;
  36393. /**
  36394. * Defines the rate of change of heightOffset.
  36395. */
  36396. heightSensibility: number;
  36397. /**
  36398. * Defines the rate of change of rotationOffset.
  36399. */
  36400. rotationSensibility: number;
  36401. /**
  36402. * Defines the rate of change of radius.
  36403. */
  36404. radiusSensibility: number;
  36405. private _keys;
  36406. private _ctrlPressed;
  36407. private _altPressed;
  36408. private _shiftPressed;
  36409. private _onCanvasBlurObserver;
  36410. private _onKeyboardObserver;
  36411. private _engine;
  36412. private _scene;
  36413. /**
  36414. * Attach the input controls to a specific dom element to get the input from.
  36415. * @param element Defines the element the controls should be listened from
  36416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36417. */
  36418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36419. /**
  36420. * Detach the current controls from the specified dom element.
  36421. * @param element Defines the element to stop listening the inputs from
  36422. */
  36423. detachControl(element: Nullable<HTMLElement>): void;
  36424. /**
  36425. * Update the current camera state depending on the inputs that have been used this frame.
  36426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36427. */
  36428. checkInputs(): void;
  36429. /**
  36430. * Gets the class name of the current input.
  36431. * @returns the class name
  36432. */
  36433. getClassName(): string;
  36434. /**
  36435. * Get the friendly name associated with the input class.
  36436. * @returns the input friendly name
  36437. */
  36438. getSimpleName(): string;
  36439. /**
  36440. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36441. * allow modification of the heightOffset value.
  36442. */
  36443. private _modifierHeightOffset;
  36444. /**
  36445. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36446. * allow modification of the rotationOffset value.
  36447. */
  36448. private _modifierRotationOffset;
  36449. /**
  36450. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36451. * allow modification of the radius value.
  36452. */
  36453. private _modifierRadius;
  36454. }
  36455. }
  36456. declare module BABYLON {
  36457. interface FreeCameraInputsManager {
  36458. /**
  36459. * @hidden
  36460. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36461. /**
  36462. * Add orientation input support to the input manager.
  36463. * @returns the current input manager
  36464. */
  36465. addDeviceOrientation(): FreeCameraInputsManager;
  36466. }
  36467. /**
  36468. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36469. * Screen rotation is taken into account.
  36470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36471. */
  36472. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36473. private _camera;
  36474. private _screenOrientationAngle;
  36475. private _constantTranform;
  36476. private _screenQuaternion;
  36477. private _alpha;
  36478. private _beta;
  36479. private _gamma;
  36480. /**
  36481. * @hidden
  36482. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  36483. /**
  36484. * Instantiates a new input
  36485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36486. */
  36487. constructor();
  36488. /**
  36489. * Define the camera controlled by the input.
  36490. */
  36491. camera: FreeCamera;
  36492. /**
  36493. * Attach the input controls to a specific dom element to get the input from.
  36494. * @param element Defines the element the controls should be listened from
  36495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36496. */
  36497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36498. private _orientationChanged;
  36499. private _deviceOrientation;
  36500. /**
  36501. * Detach the current controls from the specified dom element.
  36502. * @param element Defines the element to stop listening the inputs from
  36503. */
  36504. detachControl(element: Nullable<HTMLElement>): void;
  36505. /**
  36506. * Update the current camera state depending on the inputs that have been used this frame.
  36507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36508. */
  36509. checkInputs(): void;
  36510. /**
  36511. * Gets the class name of the current intput.
  36512. * @returns the class name
  36513. */
  36514. getClassName(): string;
  36515. /**
  36516. * Get the friendly name associated with the input class.
  36517. * @returns the input friendly name
  36518. */
  36519. getSimpleName(): string;
  36520. }
  36521. }
  36522. declare module BABYLON {
  36523. /**
  36524. * Manage the gamepad inputs to control a free camera.
  36525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36526. */
  36527. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36528. /**
  36529. * Define the camera the input is attached to.
  36530. */
  36531. camera: FreeCamera;
  36532. /**
  36533. * Define the Gamepad controlling the input
  36534. */
  36535. gamepad: Nullable<Gamepad>;
  36536. /**
  36537. * Defines the gamepad rotation sensiblity.
  36538. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36539. */
  36540. gamepadAngularSensibility: number;
  36541. /**
  36542. * Defines the gamepad move sensiblity.
  36543. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36544. */
  36545. gamepadMoveSensibility: number;
  36546. private _onGamepadConnectedObserver;
  36547. private _onGamepadDisconnectedObserver;
  36548. private _cameraTransform;
  36549. private _deltaTransform;
  36550. private _vector3;
  36551. private _vector2;
  36552. /**
  36553. * Attach the input controls to a specific dom element to get the input from.
  36554. * @param element Defines the element the controls should be listened from
  36555. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36556. */
  36557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36558. /**
  36559. * Detach the current controls from the specified dom element.
  36560. * @param element Defines the element to stop listening the inputs from
  36561. */
  36562. detachControl(element: Nullable<HTMLElement>): void;
  36563. /**
  36564. * Update the current camera state depending on the inputs that have been used this frame.
  36565. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36566. */
  36567. checkInputs(): void;
  36568. /**
  36569. * Gets the class name of the current intput.
  36570. * @returns the class name
  36571. */
  36572. getClassName(): string;
  36573. /**
  36574. * Get the friendly name associated with the input class.
  36575. * @returns the input friendly name
  36576. */
  36577. getSimpleName(): string;
  36578. }
  36579. }
  36580. declare module BABYLON {
  36581. /**
  36582. * Defines the potential axis of a Joystick
  36583. */
  36584. export enum JoystickAxis {
  36585. /** X axis */
  36586. X = 0,
  36587. /** Y axis */
  36588. Y = 1,
  36589. /** Z axis */
  36590. Z = 2
  36591. }
  36592. /**
  36593. * Class used to define virtual joystick (used in touch mode)
  36594. */
  36595. export class VirtualJoystick {
  36596. /**
  36597. * Gets or sets a boolean indicating that left and right values must be inverted
  36598. */
  36599. reverseLeftRight: boolean;
  36600. /**
  36601. * Gets or sets a boolean indicating that up and down values must be inverted
  36602. */
  36603. reverseUpDown: boolean;
  36604. /**
  36605. * Gets the offset value for the position (ie. the change of the position value)
  36606. */
  36607. deltaPosition: Vector3;
  36608. /**
  36609. * Gets a boolean indicating if the virtual joystick was pressed
  36610. */
  36611. pressed: boolean;
  36612. /**
  36613. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36614. */
  36615. static Canvas: Nullable<HTMLCanvasElement>;
  36616. private static _globalJoystickIndex;
  36617. private static vjCanvasContext;
  36618. private static vjCanvasWidth;
  36619. private static vjCanvasHeight;
  36620. private static halfWidth;
  36621. private _action;
  36622. private _axisTargetedByLeftAndRight;
  36623. private _axisTargetedByUpAndDown;
  36624. private _joystickSensibility;
  36625. private _inversedSensibility;
  36626. private _joystickPointerID;
  36627. private _joystickColor;
  36628. private _joystickPointerPos;
  36629. private _joystickPreviousPointerPos;
  36630. private _joystickPointerStartPos;
  36631. private _deltaJoystickVector;
  36632. private _leftJoystick;
  36633. private _touches;
  36634. private _onPointerDownHandlerRef;
  36635. private _onPointerMoveHandlerRef;
  36636. private _onPointerUpHandlerRef;
  36637. private _onResize;
  36638. /**
  36639. * Creates a new virtual joystick
  36640. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36641. */
  36642. constructor(leftJoystick?: boolean);
  36643. /**
  36644. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36645. * @param newJoystickSensibility defines the new sensibility
  36646. */
  36647. setJoystickSensibility(newJoystickSensibility: number): void;
  36648. private _onPointerDown;
  36649. private _onPointerMove;
  36650. private _onPointerUp;
  36651. /**
  36652. * Change the color of the virtual joystick
  36653. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36654. */
  36655. setJoystickColor(newColor: string): void;
  36656. /**
  36657. * Defines a callback to call when the joystick is touched
  36658. * @param action defines the callback
  36659. */
  36660. setActionOnTouch(action: () => any): void;
  36661. /**
  36662. * Defines which axis you'd like to control for left & right
  36663. * @param axis defines the axis to use
  36664. */
  36665. setAxisForLeftRight(axis: JoystickAxis): void;
  36666. /**
  36667. * Defines which axis you'd like to control for up & down
  36668. * @param axis defines the axis to use
  36669. */
  36670. setAxisForUpDown(axis: JoystickAxis): void;
  36671. private _drawVirtualJoystick;
  36672. /**
  36673. * Release internal HTML canvas
  36674. */
  36675. releaseCanvas(): void;
  36676. }
  36677. }
  36678. declare module BABYLON {
  36679. interface FreeCameraInputsManager {
  36680. /**
  36681. * Add virtual joystick input support to the input manager.
  36682. * @returns the current input manager
  36683. */
  36684. addVirtualJoystick(): FreeCameraInputsManager;
  36685. }
  36686. /**
  36687. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36689. */
  36690. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36691. /**
  36692. * Defines the camera the input is attached to.
  36693. */
  36694. camera: FreeCamera;
  36695. private _leftjoystick;
  36696. private _rightjoystick;
  36697. /**
  36698. * Gets the left stick of the virtual joystick.
  36699. * @returns The virtual Joystick
  36700. */
  36701. getLeftJoystick(): VirtualJoystick;
  36702. /**
  36703. * Gets the right stick of the virtual joystick.
  36704. * @returns The virtual Joystick
  36705. */
  36706. getRightJoystick(): VirtualJoystick;
  36707. /**
  36708. * Update the current camera state depending on the inputs that have been used this frame.
  36709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36710. */
  36711. checkInputs(): void;
  36712. /**
  36713. * Attach the input controls to a specific dom element to get the input from.
  36714. * @param element Defines the element the controls should be listened from
  36715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36716. */
  36717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36718. /**
  36719. * Detach the current controls from the specified dom element.
  36720. * @param element Defines the element to stop listening the inputs from
  36721. */
  36722. detachControl(element: Nullable<HTMLElement>): void;
  36723. /**
  36724. * Gets the class name of the current intput.
  36725. * @returns the class name
  36726. */
  36727. getClassName(): string;
  36728. /**
  36729. * Get the friendly name associated with the input class.
  36730. * @returns the input friendly name
  36731. */
  36732. getSimpleName(): string;
  36733. }
  36734. }
  36735. declare module BABYLON {
  36736. /**
  36737. * This represents a FPS type of camera controlled by touch.
  36738. * This is like a universal camera minus the Gamepad controls.
  36739. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36740. */
  36741. export class TouchCamera extends FreeCamera {
  36742. /**
  36743. * Defines the touch sensibility for rotation.
  36744. * The higher the faster.
  36745. */
  36746. touchAngularSensibility: number;
  36747. /**
  36748. * Defines the touch sensibility for move.
  36749. * The higher the faster.
  36750. */
  36751. touchMoveSensibility: number;
  36752. /**
  36753. * Instantiates a new touch camera.
  36754. * This represents a FPS type of camera controlled by touch.
  36755. * This is like a universal camera minus the Gamepad controls.
  36756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36757. * @param name Define the name of the camera in the scene
  36758. * @param position Define the start position of the camera in the scene
  36759. * @param scene Define the scene the camera belongs to
  36760. */
  36761. constructor(name: string, position: Vector3, scene: Scene);
  36762. /**
  36763. * Gets the current object class name.
  36764. * @return the class name
  36765. */
  36766. getClassName(): string;
  36767. /** @hidden */ private _setupInputs(): void;
  36768. }
  36769. }
  36770. declare module BABYLON {
  36771. /**
  36772. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36773. * being tilted forward or back and left or right.
  36774. */
  36775. export class DeviceOrientationCamera extends FreeCamera {
  36776. private _initialQuaternion;
  36777. private _quaternionCache;
  36778. private _tmpDragQuaternion;
  36779. /**
  36780. * Creates a new device orientation camera
  36781. * @param name The name of the camera
  36782. * @param position The start position camera
  36783. * @param scene The scene the camera belongs to
  36784. */
  36785. constructor(name: string, position: Vector3, scene: Scene);
  36786. /**
  36787. * @hidden
  36788. * Disabled pointer input on first orientation sensor update (Default: true)
  36789. */ private _disablePointerInputWhenUsingDeviceOrientation: boolean;
  36790. private _dragFactor;
  36791. /**
  36792. * Enabled turning on the y axis when the orientation sensor is active
  36793. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36794. */
  36795. enableHorizontalDragging(dragFactor?: number): void;
  36796. /**
  36797. * Gets the current instance class name ("DeviceOrientationCamera").
  36798. * This helps avoiding instanceof at run time.
  36799. * @returns the class name
  36800. */
  36801. getClassName(): string;
  36802. /**
  36803. * @hidden
  36804. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36805. */ private _checkInputs(): void;
  36806. /**
  36807. * Reset the camera to its default orientation on the specified axis only.
  36808. * @param axis The axis to reset
  36809. */
  36810. resetToCurrentRotation(axis?: Axis): void;
  36811. }
  36812. }
  36813. declare module BABYLON {
  36814. /**
  36815. * Defines supported buttons for XBox360 compatible gamepads
  36816. */
  36817. export enum Xbox360Button {
  36818. /** A */
  36819. A = 0,
  36820. /** B */
  36821. B = 1,
  36822. /** X */
  36823. X = 2,
  36824. /** Y */
  36825. Y = 3,
  36826. /** Start */
  36827. Start = 4,
  36828. /** Back */
  36829. Back = 5,
  36830. /** Left button */
  36831. LB = 6,
  36832. /** Right button */
  36833. RB = 7,
  36834. /** Left stick */
  36835. LeftStick = 8,
  36836. /** Right stick */
  36837. RightStick = 9
  36838. }
  36839. /** Defines values for XBox360 DPad */
  36840. export enum Xbox360Dpad {
  36841. /** Up */
  36842. Up = 0,
  36843. /** Down */
  36844. Down = 1,
  36845. /** Left */
  36846. Left = 2,
  36847. /** Right */
  36848. Right = 3
  36849. }
  36850. /**
  36851. * Defines a XBox360 gamepad
  36852. */
  36853. export class Xbox360Pad extends Gamepad {
  36854. private _leftTrigger;
  36855. private _rightTrigger;
  36856. private _onlefttriggerchanged;
  36857. private _onrighttriggerchanged;
  36858. private _onbuttondown;
  36859. private _onbuttonup;
  36860. private _ondpaddown;
  36861. private _ondpadup;
  36862. /** Observable raised when a button is pressed */
  36863. onButtonDownObservable: Observable<Xbox360Button>;
  36864. /** Observable raised when a button is released */
  36865. onButtonUpObservable: Observable<Xbox360Button>;
  36866. /** Observable raised when a pad is pressed */
  36867. onPadDownObservable: Observable<Xbox360Dpad>;
  36868. /** Observable raised when a pad is released */
  36869. onPadUpObservable: Observable<Xbox360Dpad>;
  36870. private _buttonA;
  36871. private _buttonB;
  36872. private _buttonX;
  36873. private _buttonY;
  36874. private _buttonBack;
  36875. private _buttonStart;
  36876. private _buttonLB;
  36877. private _buttonRB;
  36878. private _buttonLeftStick;
  36879. private _buttonRightStick;
  36880. private _dPadUp;
  36881. private _dPadDown;
  36882. private _dPadLeft;
  36883. private _dPadRight;
  36884. private _isXboxOnePad;
  36885. /**
  36886. * Creates a new XBox360 gamepad object
  36887. * @param id defines the id of this gamepad
  36888. * @param index defines its index
  36889. * @param gamepad defines the internal HTML gamepad object
  36890. * @param xboxOne defines if it is a XBox One gamepad
  36891. */
  36892. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36893. /**
  36894. * Defines the callback to call when left trigger is pressed
  36895. * @param callback defines the callback to use
  36896. */
  36897. onlefttriggerchanged(callback: (value: number) => void): void;
  36898. /**
  36899. * Defines the callback to call when right trigger is pressed
  36900. * @param callback defines the callback to use
  36901. */
  36902. onrighttriggerchanged(callback: (value: number) => void): void;
  36903. /**
  36904. * Gets the left trigger value
  36905. */
  36906. /**
  36907. * Sets the left trigger value
  36908. */
  36909. leftTrigger: number;
  36910. /**
  36911. * Gets the right trigger value
  36912. */
  36913. /**
  36914. * Sets the right trigger value
  36915. */
  36916. rightTrigger: number;
  36917. /**
  36918. * Defines the callback to call when a button is pressed
  36919. * @param callback defines the callback to use
  36920. */
  36921. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36922. /**
  36923. * Defines the callback to call when a button is released
  36924. * @param callback defines the callback to use
  36925. */
  36926. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36927. /**
  36928. * Defines the callback to call when a pad is pressed
  36929. * @param callback defines the callback to use
  36930. */
  36931. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36932. /**
  36933. * Defines the callback to call when a pad is released
  36934. * @param callback defines the callback to use
  36935. */
  36936. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36937. private _setButtonValue;
  36938. private _setDPadValue;
  36939. /**
  36940. * Gets the value of the `A` button
  36941. */
  36942. /**
  36943. * Sets the value of the `A` button
  36944. */
  36945. buttonA: number;
  36946. /**
  36947. * Gets the value of the `B` button
  36948. */
  36949. /**
  36950. * Sets the value of the `B` button
  36951. */
  36952. buttonB: number;
  36953. /**
  36954. * Gets the value of the `X` button
  36955. */
  36956. /**
  36957. * Sets the value of the `X` button
  36958. */
  36959. buttonX: number;
  36960. /**
  36961. * Gets the value of the `Y` button
  36962. */
  36963. /**
  36964. * Sets the value of the `Y` button
  36965. */
  36966. buttonY: number;
  36967. /**
  36968. * Gets the value of the `Start` button
  36969. */
  36970. /**
  36971. * Sets the value of the `Start` button
  36972. */
  36973. buttonStart: number;
  36974. /**
  36975. * Gets the value of the `Back` button
  36976. */
  36977. /**
  36978. * Sets the value of the `Back` button
  36979. */
  36980. buttonBack: number;
  36981. /**
  36982. * Gets the value of the `Left` button
  36983. */
  36984. /**
  36985. * Sets the value of the `Left` button
  36986. */
  36987. buttonLB: number;
  36988. /**
  36989. * Gets the value of the `Right` button
  36990. */
  36991. /**
  36992. * Sets the value of the `Right` button
  36993. */
  36994. buttonRB: number;
  36995. /**
  36996. * Gets the value of the Left joystick
  36997. */
  36998. /**
  36999. * Sets the value of the Left joystick
  37000. */
  37001. buttonLeftStick: number;
  37002. /**
  37003. * Gets the value of the Right joystick
  37004. */
  37005. /**
  37006. * Sets the value of the Right joystick
  37007. */
  37008. buttonRightStick: number;
  37009. /**
  37010. * Gets the value of D-pad up
  37011. */
  37012. /**
  37013. * Sets the value of D-pad up
  37014. */
  37015. dPadUp: number;
  37016. /**
  37017. * Gets the value of D-pad down
  37018. */
  37019. /**
  37020. * Sets the value of D-pad down
  37021. */
  37022. dPadDown: number;
  37023. /**
  37024. * Gets the value of D-pad left
  37025. */
  37026. /**
  37027. * Sets the value of D-pad left
  37028. */
  37029. dPadLeft: number;
  37030. /**
  37031. * Gets the value of D-pad right
  37032. */
  37033. /**
  37034. * Sets the value of D-pad right
  37035. */
  37036. dPadRight: number;
  37037. /**
  37038. * Force the gamepad to synchronize with device values
  37039. */
  37040. update(): void;
  37041. /**
  37042. * Disposes the gamepad
  37043. */
  37044. dispose(): void;
  37045. }
  37046. }
  37047. declare module BABYLON {
  37048. /**
  37049. * Manager for handling gamepads
  37050. */
  37051. export class GamepadManager {
  37052. private _scene?;
  37053. private _babylonGamepads;
  37054. private _oneGamepadConnected;
  37055. /** @hidden */ private _isMonitoring: boolean;
  37056. private _gamepadEventSupported;
  37057. private _gamepadSupport;
  37058. /**
  37059. * observable to be triggered when the gamepad controller has been connected
  37060. */
  37061. onGamepadConnectedObservable: Observable<Gamepad>;
  37062. /**
  37063. * observable to be triggered when the gamepad controller has been disconnected
  37064. */
  37065. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37066. private _onGamepadConnectedEvent;
  37067. private _onGamepadDisconnectedEvent;
  37068. /**
  37069. * Initializes the gamepad manager
  37070. * @param _scene BabylonJS scene
  37071. */
  37072. constructor(_scene?: Scene | undefined);
  37073. /**
  37074. * The gamepads in the game pad manager
  37075. */
  37076. readonly gamepads: Gamepad[];
  37077. /**
  37078. * Get the gamepad controllers based on type
  37079. * @param type The type of gamepad controller
  37080. * @returns Nullable gamepad
  37081. */
  37082. getGamepadByType(type?: number): Nullable<Gamepad>;
  37083. /**
  37084. * Disposes the gamepad manager
  37085. */
  37086. dispose(): void;
  37087. private _addNewGamepad;
  37088. private _startMonitoringGamepads;
  37089. private _stopMonitoringGamepads;
  37090. /** @hidden */ private _checkGamepadsStatus(): void;
  37091. private _updateGamepadObjects;
  37092. }
  37093. }
  37094. declare module BABYLON {
  37095. interface Scene {
  37096. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  37097. /**
  37098. * Gets the gamepad manager associated with the scene
  37099. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37100. */
  37101. gamepadManager: GamepadManager;
  37102. }
  37103. /**
  37104. * Interface representing a free camera inputs manager
  37105. */
  37106. interface FreeCameraInputsManager {
  37107. /**
  37108. * Adds gamepad input support to the FreeCameraInputsManager.
  37109. * @returns the FreeCameraInputsManager
  37110. */
  37111. addGamepad(): FreeCameraInputsManager;
  37112. }
  37113. /**
  37114. * Interface representing an arc rotate camera inputs manager
  37115. */
  37116. interface ArcRotateCameraInputsManager {
  37117. /**
  37118. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37119. * @returns the camera inputs manager
  37120. */
  37121. addGamepad(): ArcRotateCameraInputsManager;
  37122. }
  37123. /**
  37124. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37125. */
  37126. export class GamepadSystemSceneComponent implements ISceneComponent {
  37127. /**
  37128. * The component name helpfull to identify the component in the list of scene components.
  37129. */
  37130. readonly name: string;
  37131. /**
  37132. * The scene the component belongs to.
  37133. */
  37134. scene: Scene;
  37135. /**
  37136. * Creates a new instance of the component for the given scene
  37137. * @param scene Defines the scene to register the component in
  37138. */
  37139. constructor(scene: Scene);
  37140. /**
  37141. * Registers the component in a given scene
  37142. */
  37143. register(): void;
  37144. /**
  37145. * Rebuilds the elements related to this component in case of
  37146. * context lost for instance.
  37147. */
  37148. rebuild(): void;
  37149. /**
  37150. * Disposes the component and the associated ressources
  37151. */
  37152. dispose(): void;
  37153. private _beforeCameraUpdate;
  37154. }
  37155. }
  37156. declare module BABYLON {
  37157. /**
  37158. * 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,
  37159. * which still works and will still be found in many Playgrounds.
  37160. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37161. */
  37162. export class UniversalCamera extends TouchCamera {
  37163. /**
  37164. * Defines the gamepad rotation sensiblity.
  37165. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37166. */
  37167. gamepadAngularSensibility: number;
  37168. /**
  37169. * Defines the gamepad move sensiblity.
  37170. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37171. */
  37172. gamepadMoveSensibility: number;
  37173. /**
  37174. * 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,
  37175. * which still works and will still be found in many Playgrounds.
  37176. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37177. * @param name Define the name of the camera in the scene
  37178. * @param position Define the start position of the camera in the scene
  37179. * @param scene Define the scene the camera belongs to
  37180. */
  37181. constructor(name: string, position: Vector3, scene: Scene);
  37182. /**
  37183. * Gets the current object class name.
  37184. * @return the class name
  37185. */
  37186. getClassName(): string;
  37187. }
  37188. }
  37189. declare module BABYLON {
  37190. /**
  37191. * This represents a FPS type of camera. This is only here for back compat purpose.
  37192. * Please use the UniversalCamera instead as both are identical.
  37193. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37194. */
  37195. export class GamepadCamera extends UniversalCamera {
  37196. /**
  37197. * Instantiates a new Gamepad Camera
  37198. * This represents a FPS type of camera. This is only here for back compat purpose.
  37199. * Please use the UniversalCamera instead as both are identical.
  37200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37201. * @param name Define the name of the camera in the scene
  37202. * @param position Define the start position of the camera in the scene
  37203. * @param scene Define the scene the camera belongs to
  37204. */
  37205. constructor(name: string, position: Vector3, scene: Scene);
  37206. /**
  37207. * Gets the current object class name.
  37208. * @return the class name
  37209. */
  37210. getClassName(): string;
  37211. }
  37212. }
  37213. declare module BABYLON {
  37214. /** @hidden */
  37215. export var passPixelShader: {
  37216. name: string;
  37217. shader: string;
  37218. };
  37219. }
  37220. declare module BABYLON {
  37221. /** @hidden */
  37222. export var passCubePixelShader: {
  37223. name: string;
  37224. shader: string;
  37225. };
  37226. }
  37227. declare module BABYLON {
  37228. /**
  37229. * PassPostProcess which produces an output the same as it's input
  37230. */
  37231. export class PassPostProcess extends PostProcess {
  37232. /**
  37233. * Creates the PassPostProcess
  37234. * @param name The name of the effect.
  37235. * @param options The required width/height ratio to downsize to before computing the render pass.
  37236. * @param camera The camera to apply the render pass to.
  37237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37238. * @param engine The engine which the post process will be applied. (default: current engine)
  37239. * @param reusable If the post process can be reused on the same frame. (default: false)
  37240. * @param textureType The type of texture to be used when performing the post processing.
  37241. * @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)
  37242. */
  37243. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37244. }
  37245. /**
  37246. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37247. */
  37248. export class PassCubePostProcess extends PostProcess {
  37249. private _face;
  37250. /**
  37251. * Gets or sets the cube face to display.
  37252. * * 0 is +X
  37253. * * 1 is -X
  37254. * * 2 is +Y
  37255. * * 3 is -Y
  37256. * * 4 is +Z
  37257. * * 5 is -Z
  37258. */
  37259. face: number;
  37260. /**
  37261. * Creates the PassCubePostProcess
  37262. * @param name The name of the effect.
  37263. * @param options The required width/height ratio to downsize to before computing the render pass.
  37264. * @param camera The camera to apply the render pass to.
  37265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37266. * @param engine The engine which the post process will be applied. (default: current engine)
  37267. * @param reusable If the post process can be reused on the same frame. (default: false)
  37268. * @param textureType The type of texture to be used when performing the post processing.
  37269. * @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)
  37270. */
  37271. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37272. }
  37273. }
  37274. declare module BABYLON {
  37275. /** @hidden */
  37276. export var anaglyphPixelShader: {
  37277. name: string;
  37278. shader: string;
  37279. };
  37280. }
  37281. declare module BABYLON {
  37282. /**
  37283. * Postprocess used to generate anaglyphic rendering
  37284. */
  37285. export class AnaglyphPostProcess extends PostProcess {
  37286. private _passedProcess;
  37287. /**
  37288. * Creates a new AnaglyphPostProcess
  37289. * @param name defines postprocess name
  37290. * @param options defines creation options or target ratio scale
  37291. * @param rigCameras defines cameras using this postprocess
  37292. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37293. * @param engine defines hosting engine
  37294. * @param reusable defines if the postprocess will be reused multiple times per frame
  37295. */
  37296. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37297. }
  37298. }
  37299. declare module BABYLON {
  37300. /**
  37301. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37302. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37303. */
  37304. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37305. /**
  37306. * Creates a new AnaglyphArcRotateCamera
  37307. * @param name defines camera name
  37308. * @param alpha defines alpha angle (in radians)
  37309. * @param beta defines beta angle (in radians)
  37310. * @param radius defines radius
  37311. * @param target defines camera target
  37312. * @param interaxialDistance defines distance between each color axis
  37313. * @param scene defines the hosting scene
  37314. */
  37315. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37316. /**
  37317. * Gets camera class name
  37318. * @returns AnaglyphArcRotateCamera
  37319. */
  37320. getClassName(): string;
  37321. }
  37322. }
  37323. declare module BABYLON {
  37324. /**
  37325. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37326. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37327. */
  37328. export class AnaglyphFreeCamera extends FreeCamera {
  37329. /**
  37330. * Creates a new AnaglyphFreeCamera
  37331. * @param name defines camera name
  37332. * @param position defines initial position
  37333. * @param interaxialDistance defines distance between each color axis
  37334. * @param scene defines the hosting scene
  37335. */
  37336. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37337. /**
  37338. * Gets camera class name
  37339. * @returns AnaglyphFreeCamera
  37340. */
  37341. getClassName(): string;
  37342. }
  37343. }
  37344. declare module BABYLON {
  37345. /**
  37346. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37347. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37348. */
  37349. export class AnaglyphGamepadCamera extends GamepadCamera {
  37350. /**
  37351. * Creates a new AnaglyphGamepadCamera
  37352. * @param name defines camera name
  37353. * @param position defines initial position
  37354. * @param interaxialDistance defines distance between each color axis
  37355. * @param scene defines the hosting scene
  37356. */
  37357. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37358. /**
  37359. * Gets camera class name
  37360. * @returns AnaglyphGamepadCamera
  37361. */
  37362. getClassName(): string;
  37363. }
  37364. }
  37365. declare module BABYLON {
  37366. /**
  37367. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37368. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37369. */
  37370. export class AnaglyphUniversalCamera extends UniversalCamera {
  37371. /**
  37372. * Creates a new AnaglyphUniversalCamera
  37373. * @param name defines camera name
  37374. * @param position defines initial position
  37375. * @param interaxialDistance defines distance between each color axis
  37376. * @param scene defines the hosting scene
  37377. */
  37378. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37379. /**
  37380. * Gets camera class name
  37381. * @returns AnaglyphUniversalCamera
  37382. */
  37383. getClassName(): string;
  37384. }
  37385. }
  37386. declare module BABYLON {
  37387. /** @hidden */
  37388. export var stereoscopicInterlacePixelShader: {
  37389. name: string;
  37390. shader: string;
  37391. };
  37392. }
  37393. declare module BABYLON {
  37394. /**
  37395. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37396. */
  37397. export class StereoscopicInterlacePostProcess extends PostProcess {
  37398. private _stepSize;
  37399. private _passedProcess;
  37400. /**
  37401. * Initializes a StereoscopicInterlacePostProcess
  37402. * @param name The name of the effect.
  37403. * @param rigCameras The rig cameras to be appled to the post process
  37404. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37406. * @param engine The engine which the post process will be applied. (default: current engine)
  37407. * @param reusable If the post process can be reused on the same frame. (default: false)
  37408. */
  37409. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37410. }
  37411. }
  37412. declare module BABYLON {
  37413. /**
  37414. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37415. * @see http://doc.babylonjs.com/features/cameras
  37416. */
  37417. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37418. /**
  37419. * Creates a new StereoscopicArcRotateCamera
  37420. * @param name defines camera name
  37421. * @param alpha defines alpha angle (in radians)
  37422. * @param beta defines beta angle (in radians)
  37423. * @param radius defines radius
  37424. * @param target defines camera target
  37425. * @param interaxialDistance defines distance between each color axis
  37426. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37427. * @param scene defines the hosting scene
  37428. */
  37429. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37430. /**
  37431. * Gets camera class name
  37432. * @returns StereoscopicArcRotateCamera
  37433. */
  37434. getClassName(): string;
  37435. }
  37436. }
  37437. declare module BABYLON {
  37438. /**
  37439. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37440. * @see http://doc.babylonjs.com/features/cameras
  37441. */
  37442. export class StereoscopicFreeCamera extends FreeCamera {
  37443. /**
  37444. * Creates a new StereoscopicFreeCamera
  37445. * @param name defines camera name
  37446. * @param position defines initial position
  37447. * @param interaxialDistance defines distance between each color axis
  37448. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37449. * @param scene defines the hosting scene
  37450. */
  37451. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37452. /**
  37453. * Gets camera class name
  37454. * @returns StereoscopicFreeCamera
  37455. */
  37456. getClassName(): string;
  37457. }
  37458. }
  37459. declare module BABYLON {
  37460. /**
  37461. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37462. * @see http://doc.babylonjs.com/features/cameras
  37463. */
  37464. export class StereoscopicGamepadCamera extends GamepadCamera {
  37465. /**
  37466. * Creates a new StereoscopicGamepadCamera
  37467. * @param name defines camera name
  37468. * @param position defines initial position
  37469. * @param interaxialDistance defines distance between each color axis
  37470. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37471. * @param scene defines the hosting scene
  37472. */
  37473. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37474. /**
  37475. * Gets camera class name
  37476. * @returns StereoscopicGamepadCamera
  37477. */
  37478. getClassName(): string;
  37479. }
  37480. }
  37481. declare module BABYLON {
  37482. /**
  37483. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37484. * @see http://doc.babylonjs.com/features/cameras
  37485. */
  37486. export class StereoscopicUniversalCamera extends UniversalCamera {
  37487. /**
  37488. * Creates a new StereoscopicUniversalCamera
  37489. * @param name defines camera name
  37490. * @param position defines initial position
  37491. * @param interaxialDistance defines distance between each color axis
  37492. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37493. * @param scene defines the hosting scene
  37494. */
  37495. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37496. /**
  37497. * Gets camera class name
  37498. * @returns StereoscopicUniversalCamera
  37499. */
  37500. getClassName(): string;
  37501. }
  37502. }
  37503. declare module BABYLON {
  37504. /**
  37505. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37506. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37507. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37508. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37509. */
  37510. export class VirtualJoysticksCamera extends FreeCamera {
  37511. /**
  37512. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37513. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37514. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37515. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37516. * @param name Define the name of the camera in the scene
  37517. * @param position Define the start position of the camera in the scene
  37518. * @param scene Define the scene the camera belongs to
  37519. */
  37520. constructor(name: string, position: Vector3, scene: Scene);
  37521. /**
  37522. * Gets the current object class name.
  37523. * @return the class name
  37524. */
  37525. getClassName(): string;
  37526. }
  37527. }
  37528. declare module BABYLON {
  37529. /**
  37530. * This represents all the required metrics to create a VR camera.
  37531. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37532. */
  37533. export class VRCameraMetrics {
  37534. /**
  37535. * Define the horizontal resolution off the screen.
  37536. */
  37537. hResolution: number;
  37538. /**
  37539. * Define the vertical resolution off the screen.
  37540. */
  37541. vResolution: number;
  37542. /**
  37543. * Define the horizontal screen size.
  37544. */
  37545. hScreenSize: number;
  37546. /**
  37547. * Define the vertical screen size.
  37548. */
  37549. vScreenSize: number;
  37550. /**
  37551. * Define the vertical screen center position.
  37552. */
  37553. vScreenCenter: number;
  37554. /**
  37555. * Define the distance of the eyes to the screen.
  37556. */
  37557. eyeToScreenDistance: number;
  37558. /**
  37559. * Define the distance between both lenses
  37560. */
  37561. lensSeparationDistance: number;
  37562. /**
  37563. * Define the distance between both viewer's eyes.
  37564. */
  37565. interpupillaryDistance: number;
  37566. /**
  37567. * Define the distortion factor of the VR postprocess.
  37568. * Please, touch with care.
  37569. */
  37570. distortionK: number[];
  37571. /**
  37572. * Define the chromatic aberration correction factors for the VR post process.
  37573. */
  37574. chromaAbCorrection: number[];
  37575. /**
  37576. * Define the scale factor of the post process.
  37577. * The smaller the better but the slower.
  37578. */
  37579. postProcessScaleFactor: number;
  37580. /**
  37581. * Define an offset for the lens center.
  37582. */
  37583. lensCenterOffset: number;
  37584. /**
  37585. * Define if the current vr camera should compensate the distortion of the lense or not.
  37586. */
  37587. compensateDistortion: boolean;
  37588. /**
  37589. * Defines if multiview should be enabled when rendering (Default: false)
  37590. */
  37591. multiviewEnabled: boolean;
  37592. /**
  37593. * Gets the rendering aspect ratio based on the provided resolutions.
  37594. */
  37595. readonly aspectRatio: number;
  37596. /**
  37597. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37598. */
  37599. readonly aspectRatioFov: number;
  37600. /**
  37601. * @hidden
  37602. */
  37603. readonly leftHMatrix: Matrix;
  37604. /**
  37605. * @hidden
  37606. */
  37607. readonly rightHMatrix: Matrix;
  37608. /**
  37609. * @hidden
  37610. */
  37611. readonly leftPreViewMatrix: Matrix;
  37612. /**
  37613. * @hidden
  37614. */
  37615. readonly rightPreViewMatrix: Matrix;
  37616. /**
  37617. * Get the default VRMetrics based on the most generic setup.
  37618. * @returns the default vr metrics
  37619. */
  37620. static GetDefault(): VRCameraMetrics;
  37621. }
  37622. }
  37623. declare module BABYLON {
  37624. /** @hidden */
  37625. export var vrDistortionCorrectionPixelShader: {
  37626. name: string;
  37627. shader: string;
  37628. };
  37629. }
  37630. declare module BABYLON {
  37631. /**
  37632. * VRDistortionCorrectionPostProcess used for mobile VR
  37633. */
  37634. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37635. private _isRightEye;
  37636. private _distortionFactors;
  37637. private _postProcessScaleFactor;
  37638. private _lensCenterOffset;
  37639. private _scaleIn;
  37640. private _scaleFactor;
  37641. private _lensCenter;
  37642. /**
  37643. * Initializes the VRDistortionCorrectionPostProcess
  37644. * @param name The name of the effect.
  37645. * @param camera The camera to apply the render pass to.
  37646. * @param isRightEye If this is for the right eye distortion
  37647. * @param vrMetrics All the required metrics for the VR camera
  37648. */
  37649. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37650. }
  37651. }
  37652. declare module BABYLON {
  37653. /**
  37654. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37655. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37656. */
  37657. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37658. /**
  37659. * Creates a new VRDeviceOrientationArcRotateCamera
  37660. * @param name defines camera name
  37661. * @param alpha defines the camera rotation along the logitudinal axis
  37662. * @param beta defines the camera rotation along the latitudinal axis
  37663. * @param radius defines the camera distance from its target
  37664. * @param target defines the camera target
  37665. * @param scene defines the scene the camera belongs to
  37666. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37667. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37668. */
  37669. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37670. /**
  37671. * Gets camera class name
  37672. * @returns VRDeviceOrientationArcRotateCamera
  37673. */
  37674. getClassName(): string;
  37675. }
  37676. }
  37677. declare module BABYLON {
  37678. /**
  37679. * Camera used to simulate VR rendering (based on FreeCamera)
  37680. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37681. */
  37682. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37683. /**
  37684. * Creates a new VRDeviceOrientationFreeCamera
  37685. * @param name defines camera name
  37686. * @param position defines the start position of the camera
  37687. * @param scene defines the scene the camera belongs to
  37688. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37689. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37690. */
  37691. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37692. /**
  37693. * Gets camera class name
  37694. * @returns VRDeviceOrientationFreeCamera
  37695. */
  37696. getClassName(): string;
  37697. }
  37698. }
  37699. declare module BABYLON {
  37700. /**
  37701. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37702. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37703. */
  37704. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37705. /**
  37706. * Creates a new VRDeviceOrientationGamepadCamera
  37707. * @param name defines camera name
  37708. * @param position defines the start position of the camera
  37709. * @param scene defines the scene the camera belongs to
  37710. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37711. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37712. */
  37713. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37714. /**
  37715. * Gets camera class name
  37716. * @returns VRDeviceOrientationGamepadCamera
  37717. */
  37718. getClassName(): string;
  37719. }
  37720. }
  37721. declare module BABYLON {
  37722. /**
  37723. * Base class of materials working in push mode in babylon JS
  37724. * @hidden
  37725. */
  37726. export class PushMaterial extends Material {
  37727. protected _activeEffect: Effect;
  37728. protected _normalMatrix: Matrix;
  37729. /**
  37730. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37731. * This means that the material can keep using a previous shader while a new one is being compiled.
  37732. * This is mostly used when shader parallel compilation is supported (true by default)
  37733. */
  37734. allowShaderHotSwapping: boolean;
  37735. constructor(name: string, scene: Scene);
  37736. getEffect(): Effect;
  37737. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37738. /**
  37739. * Binds the given world matrix to the active effect
  37740. *
  37741. * @param world the matrix to bind
  37742. */
  37743. bindOnlyWorldMatrix(world: Matrix): void;
  37744. /**
  37745. * Binds the given normal matrix to the active effect
  37746. *
  37747. * @param normalMatrix the matrix to bind
  37748. */
  37749. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37750. bind(world: Matrix, mesh?: Mesh): void;
  37751. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37752. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37753. }
  37754. }
  37755. declare module BABYLON {
  37756. /**
  37757. * This groups all the flags used to control the materials channel.
  37758. */
  37759. export class MaterialFlags {
  37760. private static _DiffuseTextureEnabled;
  37761. /**
  37762. * Are diffuse textures enabled in the application.
  37763. */
  37764. static DiffuseTextureEnabled: boolean;
  37765. private static _AmbientTextureEnabled;
  37766. /**
  37767. * Are ambient textures enabled in the application.
  37768. */
  37769. static AmbientTextureEnabled: boolean;
  37770. private static _OpacityTextureEnabled;
  37771. /**
  37772. * Are opacity textures enabled in the application.
  37773. */
  37774. static OpacityTextureEnabled: boolean;
  37775. private static _ReflectionTextureEnabled;
  37776. /**
  37777. * Are reflection textures enabled in the application.
  37778. */
  37779. static ReflectionTextureEnabled: boolean;
  37780. private static _EmissiveTextureEnabled;
  37781. /**
  37782. * Are emissive textures enabled in the application.
  37783. */
  37784. static EmissiveTextureEnabled: boolean;
  37785. private static _SpecularTextureEnabled;
  37786. /**
  37787. * Are specular textures enabled in the application.
  37788. */
  37789. static SpecularTextureEnabled: boolean;
  37790. private static _BumpTextureEnabled;
  37791. /**
  37792. * Are bump textures enabled in the application.
  37793. */
  37794. static BumpTextureEnabled: boolean;
  37795. private static _LightmapTextureEnabled;
  37796. /**
  37797. * Are lightmap textures enabled in the application.
  37798. */
  37799. static LightmapTextureEnabled: boolean;
  37800. private static _RefractionTextureEnabled;
  37801. /**
  37802. * Are refraction textures enabled in the application.
  37803. */
  37804. static RefractionTextureEnabled: boolean;
  37805. private static _ColorGradingTextureEnabled;
  37806. /**
  37807. * Are color grading textures enabled in the application.
  37808. */
  37809. static ColorGradingTextureEnabled: boolean;
  37810. private static _FresnelEnabled;
  37811. /**
  37812. * Are fresnels enabled in the application.
  37813. */
  37814. static FresnelEnabled: boolean;
  37815. private static _ClearCoatTextureEnabled;
  37816. /**
  37817. * Are clear coat textures enabled in the application.
  37818. */
  37819. static ClearCoatTextureEnabled: boolean;
  37820. private static _ClearCoatBumpTextureEnabled;
  37821. /**
  37822. * Are clear coat bump textures enabled in the application.
  37823. */
  37824. static ClearCoatBumpTextureEnabled: boolean;
  37825. private static _ClearCoatTintTextureEnabled;
  37826. /**
  37827. * Are clear coat tint textures enabled in the application.
  37828. */
  37829. static ClearCoatTintTextureEnabled: boolean;
  37830. private static _SheenTextureEnabled;
  37831. /**
  37832. * Are sheen textures enabled in the application.
  37833. */
  37834. static SheenTextureEnabled: boolean;
  37835. private static _AnisotropicTextureEnabled;
  37836. /**
  37837. * Are anisotropic textures enabled in the application.
  37838. */
  37839. static AnisotropicTextureEnabled: boolean;
  37840. private static _ThicknessTextureEnabled;
  37841. /**
  37842. * Are thickness textures enabled in the application.
  37843. */
  37844. static ThicknessTextureEnabled: boolean;
  37845. }
  37846. }
  37847. declare module BABYLON {
  37848. /** @hidden */
  37849. export var defaultFragmentDeclaration: {
  37850. name: string;
  37851. shader: string;
  37852. };
  37853. }
  37854. declare module BABYLON {
  37855. /** @hidden */
  37856. export var defaultUboDeclaration: {
  37857. name: string;
  37858. shader: string;
  37859. };
  37860. }
  37861. declare module BABYLON {
  37862. /** @hidden */
  37863. export var lightFragmentDeclaration: {
  37864. name: string;
  37865. shader: string;
  37866. };
  37867. }
  37868. declare module BABYLON {
  37869. /** @hidden */
  37870. export var lightUboDeclaration: {
  37871. name: string;
  37872. shader: string;
  37873. };
  37874. }
  37875. declare module BABYLON {
  37876. /** @hidden */
  37877. export var lightsFragmentFunctions: {
  37878. name: string;
  37879. shader: string;
  37880. };
  37881. }
  37882. declare module BABYLON {
  37883. /** @hidden */
  37884. export var shadowsFragmentFunctions: {
  37885. name: string;
  37886. shader: string;
  37887. };
  37888. }
  37889. declare module BABYLON {
  37890. /** @hidden */
  37891. export var fresnelFunction: {
  37892. name: string;
  37893. shader: string;
  37894. };
  37895. }
  37896. declare module BABYLON {
  37897. /** @hidden */
  37898. export var reflectionFunction: {
  37899. name: string;
  37900. shader: string;
  37901. };
  37902. }
  37903. declare module BABYLON {
  37904. /** @hidden */
  37905. export var bumpFragmentFunctions: {
  37906. name: string;
  37907. shader: string;
  37908. };
  37909. }
  37910. declare module BABYLON {
  37911. /** @hidden */
  37912. export var logDepthDeclaration: {
  37913. name: string;
  37914. shader: string;
  37915. };
  37916. }
  37917. declare module BABYLON {
  37918. /** @hidden */
  37919. export var bumpFragment: {
  37920. name: string;
  37921. shader: string;
  37922. };
  37923. }
  37924. declare module BABYLON {
  37925. /** @hidden */
  37926. export var depthPrePass: {
  37927. name: string;
  37928. shader: string;
  37929. };
  37930. }
  37931. declare module BABYLON {
  37932. /** @hidden */
  37933. export var lightFragment: {
  37934. name: string;
  37935. shader: string;
  37936. };
  37937. }
  37938. declare module BABYLON {
  37939. /** @hidden */
  37940. export var logDepthFragment: {
  37941. name: string;
  37942. shader: string;
  37943. };
  37944. }
  37945. declare module BABYLON {
  37946. /** @hidden */
  37947. export var defaultPixelShader: {
  37948. name: string;
  37949. shader: string;
  37950. };
  37951. }
  37952. declare module BABYLON {
  37953. /** @hidden */
  37954. export var defaultVertexDeclaration: {
  37955. name: string;
  37956. shader: string;
  37957. };
  37958. }
  37959. declare module BABYLON {
  37960. /** @hidden */
  37961. export var bumpVertexDeclaration: {
  37962. name: string;
  37963. shader: string;
  37964. };
  37965. }
  37966. declare module BABYLON {
  37967. /** @hidden */
  37968. export var bumpVertex: {
  37969. name: string;
  37970. shader: string;
  37971. };
  37972. }
  37973. declare module BABYLON {
  37974. /** @hidden */
  37975. export var fogVertex: {
  37976. name: string;
  37977. shader: string;
  37978. };
  37979. }
  37980. declare module BABYLON {
  37981. /** @hidden */
  37982. export var shadowsVertex: {
  37983. name: string;
  37984. shader: string;
  37985. };
  37986. }
  37987. declare module BABYLON {
  37988. /** @hidden */
  37989. export var pointCloudVertex: {
  37990. name: string;
  37991. shader: string;
  37992. };
  37993. }
  37994. declare module BABYLON {
  37995. /** @hidden */
  37996. export var logDepthVertex: {
  37997. name: string;
  37998. shader: string;
  37999. };
  38000. }
  38001. declare module BABYLON {
  38002. /** @hidden */
  38003. export var defaultVertexShader: {
  38004. name: string;
  38005. shader: string;
  38006. };
  38007. }
  38008. declare module BABYLON {
  38009. /** @hidden */
  38010. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38011. MAINUV1: boolean;
  38012. MAINUV2: boolean;
  38013. DIFFUSE: boolean;
  38014. DIFFUSEDIRECTUV: number;
  38015. AMBIENT: boolean;
  38016. AMBIENTDIRECTUV: number;
  38017. OPACITY: boolean;
  38018. OPACITYDIRECTUV: number;
  38019. OPACITYRGB: boolean;
  38020. REFLECTION: boolean;
  38021. EMISSIVE: boolean;
  38022. EMISSIVEDIRECTUV: number;
  38023. SPECULAR: boolean;
  38024. SPECULARDIRECTUV: number;
  38025. BUMP: boolean;
  38026. BUMPDIRECTUV: number;
  38027. PARALLAX: boolean;
  38028. PARALLAXOCCLUSION: boolean;
  38029. SPECULAROVERALPHA: boolean;
  38030. CLIPPLANE: boolean;
  38031. CLIPPLANE2: boolean;
  38032. CLIPPLANE3: boolean;
  38033. CLIPPLANE4: boolean;
  38034. ALPHATEST: boolean;
  38035. DEPTHPREPASS: boolean;
  38036. ALPHAFROMDIFFUSE: boolean;
  38037. POINTSIZE: boolean;
  38038. FOG: boolean;
  38039. SPECULARTERM: boolean;
  38040. DIFFUSEFRESNEL: boolean;
  38041. OPACITYFRESNEL: boolean;
  38042. REFLECTIONFRESNEL: boolean;
  38043. REFRACTIONFRESNEL: boolean;
  38044. EMISSIVEFRESNEL: boolean;
  38045. FRESNEL: boolean;
  38046. NORMAL: boolean;
  38047. UV1: boolean;
  38048. UV2: boolean;
  38049. VERTEXCOLOR: boolean;
  38050. VERTEXALPHA: boolean;
  38051. NUM_BONE_INFLUENCERS: number;
  38052. BonesPerMesh: number;
  38053. BONETEXTURE: boolean;
  38054. INSTANCES: boolean;
  38055. GLOSSINESS: boolean;
  38056. ROUGHNESS: boolean;
  38057. EMISSIVEASILLUMINATION: boolean;
  38058. LINKEMISSIVEWITHDIFFUSE: boolean;
  38059. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38060. LIGHTMAP: boolean;
  38061. LIGHTMAPDIRECTUV: number;
  38062. OBJECTSPACE_NORMALMAP: boolean;
  38063. USELIGHTMAPASSHADOWMAP: boolean;
  38064. REFLECTIONMAP_3D: boolean;
  38065. REFLECTIONMAP_SPHERICAL: boolean;
  38066. REFLECTIONMAP_PLANAR: boolean;
  38067. REFLECTIONMAP_CUBIC: boolean;
  38068. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38069. REFLECTIONMAP_PROJECTION: boolean;
  38070. REFLECTIONMAP_SKYBOX: boolean;
  38071. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38072. REFLECTIONMAP_EXPLICIT: boolean;
  38073. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38074. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38075. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38076. INVERTCUBICMAP: boolean;
  38077. LOGARITHMICDEPTH: boolean;
  38078. REFRACTION: boolean;
  38079. REFRACTIONMAP_3D: boolean;
  38080. REFLECTIONOVERALPHA: boolean;
  38081. TWOSIDEDLIGHTING: boolean;
  38082. SHADOWFLOAT: boolean;
  38083. MORPHTARGETS: boolean;
  38084. MORPHTARGETS_NORMAL: boolean;
  38085. MORPHTARGETS_TANGENT: boolean;
  38086. NUM_MORPH_INFLUENCERS: number;
  38087. NONUNIFORMSCALING: boolean;
  38088. PREMULTIPLYALPHA: boolean;
  38089. IMAGEPROCESSING: boolean;
  38090. VIGNETTE: boolean;
  38091. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38092. VIGNETTEBLENDMODEOPAQUE: boolean;
  38093. TONEMAPPING: boolean;
  38094. TONEMAPPING_ACES: boolean;
  38095. CONTRAST: boolean;
  38096. COLORCURVES: boolean;
  38097. COLORGRADING: boolean;
  38098. COLORGRADING3D: boolean;
  38099. SAMPLER3DGREENDEPTH: boolean;
  38100. SAMPLER3DBGRMAP: boolean;
  38101. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38102. MULTIVIEW: boolean;
  38103. /**
  38104. * If the reflection texture on this material is in linear color space
  38105. * @hidden
  38106. */
  38107. IS_REFLECTION_LINEAR: boolean;
  38108. /**
  38109. * If the refraction texture on this material is in linear color space
  38110. * @hidden
  38111. */
  38112. IS_REFRACTION_LINEAR: boolean;
  38113. EXPOSURE: boolean;
  38114. constructor();
  38115. setReflectionMode(modeToEnable: string): void;
  38116. }
  38117. /**
  38118. * This is the default material used in Babylon. It is the best trade off between quality
  38119. * and performances.
  38120. * @see http://doc.babylonjs.com/babylon101/materials
  38121. */
  38122. export class StandardMaterial extends PushMaterial {
  38123. private _diffuseTexture;
  38124. /**
  38125. * The basic texture of the material as viewed under a light.
  38126. */
  38127. diffuseTexture: Nullable<BaseTexture>;
  38128. private _ambientTexture;
  38129. /**
  38130. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38131. */
  38132. ambientTexture: Nullable<BaseTexture>;
  38133. private _opacityTexture;
  38134. /**
  38135. * Define the transparency of the material from a texture.
  38136. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38137. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38138. */
  38139. opacityTexture: Nullable<BaseTexture>;
  38140. private _reflectionTexture;
  38141. /**
  38142. * Define the texture used to display the reflection.
  38143. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38144. */
  38145. reflectionTexture: Nullable<BaseTexture>;
  38146. private _emissiveTexture;
  38147. /**
  38148. * Define texture of the material as if self lit.
  38149. * This will be mixed in the final result even in the absence of light.
  38150. */
  38151. emissiveTexture: Nullable<BaseTexture>;
  38152. private _specularTexture;
  38153. /**
  38154. * Define how the color and intensity of the highlight given by the light in the material.
  38155. */
  38156. specularTexture: Nullable<BaseTexture>;
  38157. private _bumpTexture;
  38158. /**
  38159. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38160. * 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.
  38161. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38162. */
  38163. bumpTexture: Nullable<BaseTexture>;
  38164. private _lightmapTexture;
  38165. /**
  38166. * Complex lighting can be computationally expensive to compute at runtime.
  38167. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38168. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38169. */
  38170. lightmapTexture: Nullable<BaseTexture>;
  38171. private _refractionTexture;
  38172. /**
  38173. * Define the texture used to display the refraction.
  38174. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38175. */
  38176. refractionTexture: Nullable<BaseTexture>;
  38177. /**
  38178. * The color of the material lit by the environmental background lighting.
  38179. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38180. */
  38181. ambientColor: Color3;
  38182. /**
  38183. * The basic color of the material as viewed under a light.
  38184. */
  38185. diffuseColor: Color3;
  38186. /**
  38187. * Define how the color and intensity of the highlight given by the light in the material.
  38188. */
  38189. specularColor: Color3;
  38190. /**
  38191. * Define the color of the material as if self lit.
  38192. * This will be mixed in the final result even in the absence of light.
  38193. */
  38194. emissiveColor: Color3;
  38195. /**
  38196. * Defines how sharp are the highlights in the material.
  38197. * The bigger the value the sharper giving a more glossy feeling to the result.
  38198. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38199. */
  38200. specularPower: number;
  38201. private _useAlphaFromDiffuseTexture;
  38202. /**
  38203. * Does the transparency come from the diffuse texture alpha channel.
  38204. */
  38205. useAlphaFromDiffuseTexture: boolean;
  38206. private _useEmissiveAsIllumination;
  38207. /**
  38208. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38209. */
  38210. useEmissiveAsIllumination: boolean;
  38211. private _linkEmissiveWithDiffuse;
  38212. /**
  38213. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38214. * the emissive level when the final color is close to one.
  38215. */
  38216. linkEmissiveWithDiffuse: boolean;
  38217. private _useSpecularOverAlpha;
  38218. /**
  38219. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38220. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38221. */
  38222. useSpecularOverAlpha: boolean;
  38223. private _useReflectionOverAlpha;
  38224. /**
  38225. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38226. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38227. */
  38228. useReflectionOverAlpha: boolean;
  38229. private _disableLighting;
  38230. /**
  38231. * Does lights from the scene impacts this material.
  38232. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38233. */
  38234. disableLighting: boolean;
  38235. private _useObjectSpaceNormalMap;
  38236. /**
  38237. * Allows using an object space normal map (instead of tangent space).
  38238. */
  38239. useObjectSpaceNormalMap: boolean;
  38240. private _useParallax;
  38241. /**
  38242. * Is parallax enabled or not.
  38243. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38244. */
  38245. useParallax: boolean;
  38246. private _useParallaxOcclusion;
  38247. /**
  38248. * Is parallax occlusion enabled or not.
  38249. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38250. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38251. */
  38252. useParallaxOcclusion: boolean;
  38253. /**
  38254. * 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.
  38255. */
  38256. parallaxScaleBias: number;
  38257. private _roughness;
  38258. /**
  38259. * Helps to define how blurry the reflections should appears in the material.
  38260. */
  38261. roughness: number;
  38262. /**
  38263. * In case of refraction, define the value of the indice of refraction.
  38264. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38265. */
  38266. indexOfRefraction: number;
  38267. /**
  38268. * Invert the refraction texture alongside the y axis.
  38269. * It can be useful with procedural textures or probe for instance.
  38270. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38271. */
  38272. invertRefractionY: boolean;
  38273. /**
  38274. * Defines the alpha limits in alpha test mode.
  38275. */
  38276. alphaCutOff: number;
  38277. private _useLightmapAsShadowmap;
  38278. /**
  38279. * In case of light mapping, define whether the map contains light or shadow informations.
  38280. */
  38281. useLightmapAsShadowmap: boolean;
  38282. private _diffuseFresnelParameters;
  38283. /**
  38284. * Define the diffuse fresnel parameters of the material.
  38285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38286. */
  38287. diffuseFresnelParameters: FresnelParameters;
  38288. private _opacityFresnelParameters;
  38289. /**
  38290. * Define the opacity fresnel parameters of the material.
  38291. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38292. */
  38293. opacityFresnelParameters: FresnelParameters;
  38294. private _reflectionFresnelParameters;
  38295. /**
  38296. * Define the reflection fresnel parameters of the material.
  38297. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38298. */
  38299. reflectionFresnelParameters: FresnelParameters;
  38300. private _refractionFresnelParameters;
  38301. /**
  38302. * Define the refraction fresnel parameters of the material.
  38303. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38304. */
  38305. refractionFresnelParameters: FresnelParameters;
  38306. private _emissiveFresnelParameters;
  38307. /**
  38308. * Define the emissive fresnel parameters of the material.
  38309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38310. */
  38311. emissiveFresnelParameters: FresnelParameters;
  38312. private _useReflectionFresnelFromSpecular;
  38313. /**
  38314. * If true automatically deducts the fresnels values from the material specularity.
  38315. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38316. */
  38317. useReflectionFresnelFromSpecular: boolean;
  38318. private _useGlossinessFromSpecularMapAlpha;
  38319. /**
  38320. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38321. */
  38322. useGlossinessFromSpecularMapAlpha: boolean;
  38323. private _maxSimultaneousLights;
  38324. /**
  38325. * Defines the maximum number of lights that can be used in the material
  38326. */
  38327. maxSimultaneousLights: number;
  38328. private _invertNormalMapX;
  38329. /**
  38330. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38331. */
  38332. invertNormalMapX: boolean;
  38333. private _invertNormalMapY;
  38334. /**
  38335. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38336. */
  38337. invertNormalMapY: boolean;
  38338. private _twoSidedLighting;
  38339. /**
  38340. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38341. */
  38342. twoSidedLighting: boolean;
  38343. /**
  38344. * Default configuration related to image processing available in the standard Material.
  38345. */
  38346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38347. /**
  38348. * Gets the image processing configuration used either in this material.
  38349. */
  38350. /**
  38351. * Sets the Default image processing configuration used either in the this material.
  38352. *
  38353. * If sets to null, the scene one is in use.
  38354. */
  38355. imageProcessingConfiguration: ImageProcessingConfiguration;
  38356. /**
  38357. * Keep track of the image processing observer to allow dispose and replace.
  38358. */
  38359. private _imageProcessingObserver;
  38360. /**
  38361. * Attaches a new image processing configuration to the Standard Material.
  38362. * @param configuration
  38363. */
  38364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38365. /**
  38366. * Gets wether the color curves effect is enabled.
  38367. */
  38368. /**
  38369. * Sets wether the color curves effect is enabled.
  38370. */
  38371. cameraColorCurvesEnabled: boolean;
  38372. /**
  38373. * Gets wether the color grading effect is enabled.
  38374. */
  38375. /**
  38376. * Gets wether the color grading effect is enabled.
  38377. */
  38378. cameraColorGradingEnabled: boolean;
  38379. /**
  38380. * Gets wether tonemapping is enabled or not.
  38381. */
  38382. /**
  38383. * Sets wether tonemapping is enabled or not
  38384. */
  38385. cameraToneMappingEnabled: boolean;
  38386. /**
  38387. * The camera exposure used on this material.
  38388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38389. * This corresponds to a photographic exposure.
  38390. */
  38391. /**
  38392. * The camera exposure used on this material.
  38393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38394. * This corresponds to a photographic exposure.
  38395. */
  38396. cameraExposure: number;
  38397. /**
  38398. * Gets The camera contrast used on this material.
  38399. */
  38400. /**
  38401. * Sets The camera contrast used on this material.
  38402. */
  38403. cameraContrast: number;
  38404. /**
  38405. * Gets the Color Grading 2D Lookup Texture.
  38406. */
  38407. /**
  38408. * Sets the Color Grading 2D Lookup Texture.
  38409. */
  38410. cameraColorGradingTexture: Nullable<BaseTexture>;
  38411. /**
  38412. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38413. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38414. * 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;
  38415. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38416. */
  38417. /**
  38418. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38419. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38420. * 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;
  38421. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38422. */
  38423. cameraColorCurves: Nullable<ColorCurves>;
  38424. /**
  38425. * Custom callback helping to override the default shader used in the material.
  38426. */
  38427. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38428. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38429. protected _worldViewProjectionMatrix: Matrix;
  38430. protected _globalAmbientColor: Color3;
  38431. protected _useLogarithmicDepth: boolean;
  38432. /**
  38433. * Instantiates a new standard material.
  38434. * This is the default material used in Babylon. It is the best trade off between quality
  38435. * and performances.
  38436. * @see http://doc.babylonjs.com/babylon101/materials
  38437. * @param name Define the name of the material in the scene
  38438. * @param scene Define the scene the material belong to
  38439. */
  38440. constructor(name: string, scene: Scene);
  38441. /**
  38442. * Gets a boolean indicating that current material needs to register RTT
  38443. */
  38444. readonly hasRenderTargetTextures: boolean;
  38445. /**
  38446. * Gets the current class name of the material e.g. "StandardMaterial"
  38447. * Mainly use in serialization.
  38448. * @returns the class name
  38449. */
  38450. getClassName(): string;
  38451. /**
  38452. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38453. * You can try switching to logarithmic depth.
  38454. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38455. */
  38456. useLogarithmicDepth: boolean;
  38457. /**
  38458. * Specifies if the material will require alpha blending
  38459. * @returns a boolean specifying if alpha blending is needed
  38460. */
  38461. needAlphaBlending(): boolean;
  38462. /**
  38463. * Specifies if this material should be rendered in alpha test mode
  38464. * @returns a boolean specifying if an alpha test is needed.
  38465. */
  38466. needAlphaTesting(): boolean;
  38467. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38468. /**
  38469. * Get the texture used for alpha test purpose.
  38470. * @returns the diffuse texture in case of the standard material.
  38471. */
  38472. getAlphaTestTexture(): Nullable<BaseTexture>;
  38473. /**
  38474. * Get if the submesh is ready to be used and all its information available.
  38475. * Child classes can use it to update shaders
  38476. * @param mesh defines the mesh to check
  38477. * @param subMesh defines which submesh to check
  38478. * @param useInstances specifies that instances should be used
  38479. * @returns a boolean indicating that the submesh is ready or not
  38480. */
  38481. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38482. /**
  38483. * Builds the material UBO layouts.
  38484. * Used internally during the effect preparation.
  38485. */
  38486. buildUniformLayout(): void;
  38487. /**
  38488. * Unbinds the material from the mesh
  38489. */
  38490. unbind(): void;
  38491. /**
  38492. * Binds the submesh to this material by preparing the effect and shader to draw
  38493. * @param world defines the world transformation matrix
  38494. * @param mesh defines the mesh containing the submesh
  38495. * @param subMesh defines the submesh to bind the material to
  38496. */
  38497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38498. /**
  38499. * Get the list of animatables in the material.
  38500. * @returns the list of animatables object used in the material
  38501. */
  38502. getAnimatables(): IAnimatable[];
  38503. /**
  38504. * Gets the active textures from the material
  38505. * @returns an array of textures
  38506. */
  38507. getActiveTextures(): BaseTexture[];
  38508. /**
  38509. * Specifies if the material uses a texture
  38510. * @param texture defines the texture to check against the material
  38511. * @returns a boolean specifying if the material uses the texture
  38512. */
  38513. hasTexture(texture: BaseTexture): boolean;
  38514. /**
  38515. * Disposes the material
  38516. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38517. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38518. */
  38519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38520. /**
  38521. * Makes a duplicate of the material, and gives it a new name
  38522. * @param name defines the new name for the duplicated material
  38523. * @returns the cloned material
  38524. */
  38525. clone(name: string): StandardMaterial;
  38526. /**
  38527. * Serializes this material in a JSON representation
  38528. * @returns the serialized material object
  38529. */
  38530. serialize(): any;
  38531. /**
  38532. * Creates a standard material from parsed material data
  38533. * @param source defines the JSON representation of the material
  38534. * @param scene defines the hosting scene
  38535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38536. * @returns a new standard material
  38537. */
  38538. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38539. /**
  38540. * Are diffuse textures enabled in the application.
  38541. */
  38542. static DiffuseTextureEnabled: boolean;
  38543. /**
  38544. * Are ambient textures enabled in the application.
  38545. */
  38546. static AmbientTextureEnabled: boolean;
  38547. /**
  38548. * Are opacity textures enabled in the application.
  38549. */
  38550. static OpacityTextureEnabled: boolean;
  38551. /**
  38552. * Are reflection textures enabled in the application.
  38553. */
  38554. static ReflectionTextureEnabled: boolean;
  38555. /**
  38556. * Are emissive textures enabled in the application.
  38557. */
  38558. static EmissiveTextureEnabled: boolean;
  38559. /**
  38560. * Are specular textures enabled in the application.
  38561. */
  38562. static SpecularTextureEnabled: boolean;
  38563. /**
  38564. * Are bump textures enabled in the application.
  38565. */
  38566. static BumpTextureEnabled: boolean;
  38567. /**
  38568. * Are lightmap textures enabled in the application.
  38569. */
  38570. static LightmapTextureEnabled: boolean;
  38571. /**
  38572. * Are refraction textures enabled in the application.
  38573. */
  38574. static RefractionTextureEnabled: boolean;
  38575. /**
  38576. * Are color grading textures enabled in the application.
  38577. */
  38578. static ColorGradingTextureEnabled: boolean;
  38579. /**
  38580. * Are fresnels enabled in the application.
  38581. */
  38582. static FresnelEnabled: boolean;
  38583. }
  38584. }
  38585. declare module BABYLON {
  38586. /**
  38587. * A class extending Texture allowing drawing on a texture
  38588. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38589. */
  38590. export class DynamicTexture extends Texture {
  38591. private _generateMipMaps;
  38592. private _canvas;
  38593. private _context;
  38594. private _engine;
  38595. /**
  38596. * Creates a DynamicTexture
  38597. * @param name defines the name of the texture
  38598. * @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
  38599. * @param scene defines the scene where you want the texture
  38600. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38601. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38602. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38603. */
  38604. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38605. /**
  38606. * Get the current class name of the texture useful for serialization or dynamic coding.
  38607. * @returns "DynamicTexture"
  38608. */
  38609. getClassName(): string;
  38610. /**
  38611. * Gets the current state of canRescale
  38612. */
  38613. readonly canRescale: boolean;
  38614. private _recreate;
  38615. /**
  38616. * Scales the texture
  38617. * @param ratio the scale factor to apply to both width and height
  38618. */
  38619. scale(ratio: number): void;
  38620. /**
  38621. * Resizes the texture
  38622. * @param width the new width
  38623. * @param height the new height
  38624. */
  38625. scaleTo(width: number, height: number): void;
  38626. /**
  38627. * Gets the context of the canvas used by the texture
  38628. * @returns the canvas context of the dynamic texture
  38629. */
  38630. getContext(): CanvasRenderingContext2D;
  38631. /**
  38632. * Clears the texture
  38633. */
  38634. clear(): void;
  38635. /**
  38636. * Updates the texture
  38637. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38638. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38639. */
  38640. update(invertY?: boolean, premulAlpha?: boolean): void;
  38641. /**
  38642. * Draws text onto the texture
  38643. * @param text defines the text to be drawn
  38644. * @param x defines the placement of the text from the left
  38645. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38646. * @param font defines the font to be used with font-style, font-size, font-name
  38647. * @param color defines the color used for the text
  38648. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38650. * @param update defines whether texture is immediately update (default is true)
  38651. */
  38652. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38653. /**
  38654. * Clones the texture
  38655. * @returns the clone of the texture.
  38656. */
  38657. clone(): DynamicTexture;
  38658. /**
  38659. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38660. * @returns a serialized dynamic texture object
  38661. */
  38662. serialize(): any;
  38663. /** @hidden */ private _rebuild(): void;
  38664. }
  38665. }
  38666. declare module BABYLON {
  38667. /** @hidden */
  38668. export var imageProcessingPixelShader: {
  38669. name: string;
  38670. shader: string;
  38671. };
  38672. }
  38673. declare module BABYLON {
  38674. /**
  38675. * ImageProcessingPostProcess
  38676. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38677. */
  38678. export class ImageProcessingPostProcess extends PostProcess {
  38679. /**
  38680. * Default configuration related to image processing available in the PBR Material.
  38681. */
  38682. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38683. /**
  38684. * Gets the image processing configuration used either in this material.
  38685. */
  38686. /**
  38687. * Sets the Default image processing configuration used either in the this material.
  38688. *
  38689. * If sets to null, the scene one is in use.
  38690. */
  38691. imageProcessingConfiguration: ImageProcessingConfiguration;
  38692. /**
  38693. * Keep track of the image processing observer to allow dispose and replace.
  38694. */
  38695. private _imageProcessingObserver;
  38696. /**
  38697. * Attaches a new image processing configuration to the PBR Material.
  38698. * @param configuration
  38699. */
  38700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38701. /**
  38702. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38703. */
  38704. /**
  38705. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38706. */
  38707. colorCurves: Nullable<ColorCurves>;
  38708. /**
  38709. * Gets wether the color curves effect is enabled.
  38710. */
  38711. /**
  38712. * Sets wether the color curves effect is enabled.
  38713. */
  38714. colorCurvesEnabled: boolean;
  38715. /**
  38716. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38717. */
  38718. /**
  38719. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38720. */
  38721. colorGradingTexture: Nullable<BaseTexture>;
  38722. /**
  38723. * Gets wether the color grading effect is enabled.
  38724. */
  38725. /**
  38726. * Gets wether the color grading effect is enabled.
  38727. */
  38728. colorGradingEnabled: boolean;
  38729. /**
  38730. * Gets exposure used in the effect.
  38731. */
  38732. /**
  38733. * Sets exposure used in the effect.
  38734. */
  38735. exposure: number;
  38736. /**
  38737. * Gets wether tonemapping is enabled or not.
  38738. */
  38739. /**
  38740. * Sets wether tonemapping is enabled or not
  38741. */
  38742. toneMappingEnabled: boolean;
  38743. /**
  38744. * Gets the type of tone mapping effect.
  38745. */
  38746. /**
  38747. * Sets the type of tone mapping effect.
  38748. */
  38749. toneMappingType: number;
  38750. /**
  38751. * Gets contrast used in the effect.
  38752. */
  38753. /**
  38754. * Sets contrast used in the effect.
  38755. */
  38756. contrast: number;
  38757. /**
  38758. * Gets Vignette stretch size.
  38759. */
  38760. /**
  38761. * Sets Vignette stretch size.
  38762. */
  38763. vignetteStretch: number;
  38764. /**
  38765. * Gets Vignette centre X Offset.
  38766. */
  38767. /**
  38768. * Sets Vignette centre X Offset.
  38769. */
  38770. vignetteCentreX: number;
  38771. /**
  38772. * Gets Vignette centre Y Offset.
  38773. */
  38774. /**
  38775. * Sets Vignette centre Y Offset.
  38776. */
  38777. vignetteCentreY: number;
  38778. /**
  38779. * Gets Vignette weight or intensity of the vignette effect.
  38780. */
  38781. /**
  38782. * Sets Vignette weight or intensity of the vignette effect.
  38783. */
  38784. vignetteWeight: number;
  38785. /**
  38786. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38787. * if vignetteEnabled is set to true.
  38788. */
  38789. /**
  38790. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38791. * if vignetteEnabled is set to true.
  38792. */
  38793. vignetteColor: Color4;
  38794. /**
  38795. * Gets Camera field of view used by the Vignette effect.
  38796. */
  38797. /**
  38798. * Sets Camera field of view used by the Vignette effect.
  38799. */
  38800. vignetteCameraFov: number;
  38801. /**
  38802. * Gets the vignette blend mode allowing different kind of effect.
  38803. */
  38804. /**
  38805. * Sets the vignette blend mode allowing different kind of effect.
  38806. */
  38807. vignetteBlendMode: number;
  38808. /**
  38809. * Gets wether the vignette effect is enabled.
  38810. */
  38811. /**
  38812. * Sets wether the vignette effect is enabled.
  38813. */
  38814. vignetteEnabled: boolean;
  38815. private _fromLinearSpace;
  38816. /**
  38817. * Gets wether the input of the processing is in Gamma or Linear Space.
  38818. */
  38819. /**
  38820. * Sets wether the input of the processing is in Gamma or Linear Space.
  38821. */
  38822. fromLinearSpace: boolean;
  38823. /**
  38824. * Defines cache preventing GC.
  38825. */
  38826. private _defines;
  38827. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38828. /**
  38829. * "ImageProcessingPostProcess"
  38830. * @returns "ImageProcessingPostProcess"
  38831. */
  38832. getClassName(): string;
  38833. protected _updateParameters(): void;
  38834. dispose(camera?: Camera): void;
  38835. }
  38836. }
  38837. declare module BABYLON {
  38838. /**
  38839. * Class containing static functions to help procedurally build meshes
  38840. */
  38841. export class GroundBuilder {
  38842. /**
  38843. * Creates a ground mesh
  38844. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38845. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38847. * @param name defines the name of the mesh
  38848. * @param options defines the options used to create the mesh
  38849. * @param scene defines the hosting scene
  38850. * @returns the ground mesh
  38851. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38852. */
  38853. static CreateGround(name: string, options: {
  38854. width?: number;
  38855. height?: number;
  38856. subdivisions?: number;
  38857. subdivisionsX?: number;
  38858. subdivisionsY?: number;
  38859. updatable?: boolean;
  38860. }, scene: any): Mesh;
  38861. /**
  38862. * Creates a tiled ground mesh
  38863. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38864. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38865. * * 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
  38866. * * 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
  38867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38868. * @param name defines the name of the mesh
  38869. * @param options defines the options used to create the mesh
  38870. * @param scene defines the hosting scene
  38871. * @returns the tiled ground mesh
  38872. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38873. */
  38874. static CreateTiledGround(name: string, options: {
  38875. xmin: number;
  38876. zmin: number;
  38877. xmax: number;
  38878. zmax: number;
  38879. subdivisions?: {
  38880. w: number;
  38881. h: number;
  38882. };
  38883. precision?: {
  38884. w: number;
  38885. h: number;
  38886. };
  38887. updatable?: boolean;
  38888. }, scene?: Nullable<Scene>): Mesh;
  38889. /**
  38890. * Creates a ground mesh from a height map
  38891. * * The parameter `url` sets the URL of the height map image resource.
  38892. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38893. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38894. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38895. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38896. * * 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.
  38897. * * 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).
  38898. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38900. * @param name defines the name of the mesh
  38901. * @param url defines the url to the height map
  38902. * @param options defines the options used to create the mesh
  38903. * @param scene defines the hosting scene
  38904. * @returns the ground mesh
  38905. * @see https://doc.babylonjs.com/babylon101/height_map
  38906. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38907. */
  38908. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38909. width?: number;
  38910. height?: number;
  38911. subdivisions?: number;
  38912. minHeight?: number;
  38913. maxHeight?: number;
  38914. colorFilter?: Color3;
  38915. alphaFilter?: number;
  38916. updatable?: boolean;
  38917. onReady?: (mesh: GroundMesh) => void;
  38918. }, scene?: Nullable<Scene>): GroundMesh;
  38919. }
  38920. }
  38921. declare module BABYLON {
  38922. /**
  38923. * Class containing static functions to help procedurally build meshes
  38924. */
  38925. export class TorusBuilder {
  38926. /**
  38927. * Creates a torus mesh
  38928. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38929. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38930. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38932. * * 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
  38933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38934. * @param name defines the name of the mesh
  38935. * @param options defines the options used to create the mesh
  38936. * @param scene defines the hosting scene
  38937. * @returns the torus mesh
  38938. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38939. */
  38940. static CreateTorus(name: string, options: {
  38941. diameter?: number;
  38942. thickness?: number;
  38943. tessellation?: number;
  38944. updatable?: boolean;
  38945. sideOrientation?: number;
  38946. frontUVs?: Vector4;
  38947. backUVs?: Vector4;
  38948. }, scene: any): Mesh;
  38949. }
  38950. }
  38951. declare module BABYLON {
  38952. /**
  38953. * Class containing static functions to help procedurally build meshes
  38954. */
  38955. export class CylinderBuilder {
  38956. /**
  38957. * Creates a cylinder or a cone mesh
  38958. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38959. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38960. * * 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.
  38961. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38962. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38963. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38964. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38965. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  38966. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38967. * * 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).
  38968. * * 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
  38969. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38970. * * 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
  38971. * * 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.
  38972. * * If `enclose` is false, a ring surface is one element.
  38973. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38974. * * 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
  38975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38976. * * 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
  38977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38978. * @param name defines the name of the mesh
  38979. * @param options defines the options used to create the mesh
  38980. * @param scene defines the hosting scene
  38981. * @returns the cylinder mesh
  38982. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38983. */
  38984. static CreateCylinder(name: string, options: {
  38985. height?: number;
  38986. diameterTop?: number;
  38987. diameterBottom?: number;
  38988. diameter?: number;
  38989. tessellation?: number;
  38990. subdivisions?: number;
  38991. arc?: number;
  38992. faceColors?: Color4[];
  38993. faceUV?: Vector4[];
  38994. updatable?: boolean;
  38995. hasRings?: boolean;
  38996. enclose?: boolean;
  38997. cap?: number;
  38998. sideOrientation?: number;
  38999. frontUVs?: Vector4;
  39000. backUVs?: Vector4;
  39001. }, scene: any): Mesh;
  39002. }
  39003. }
  39004. declare module BABYLON {
  39005. /**
  39006. * Options to modify the vr teleportation behavior.
  39007. */
  39008. export interface VRTeleportationOptions {
  39009. /**
  39010. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39011. */
  39012. floorMeshName?: string;
  39013. /**
  39014. * A list of meshes to be used as the teleportation floor. (default: empty)
  39015. */
  39016. floorMeshes?: Mesh[];
  39017. }
  39018. /**
  39019. * Options to modify the vr experience helper's behavior.
  39020. */
  39021. export interface VRExperienceHelperOptions extends WebVROptions {
  39022. /**
  39023. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39024. */
  39025. createDeviceOrientationCamera?: boolean;
  39026. /**
  39027. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39028. */
  39029. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39030. /**
  39031. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39032. */
  39033. laserToggle?: boolean;
  39034. /**
  39035. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39036. */
  39037. floorMeshes?: Mesh[];
  39038. /**
  39039. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39040. */
  39041. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39042. }
  39043. /**
  39044. * Event containing information after VR has been entered
  39045. */
  39046. export class OnAfterEnteringVRObservableEvent {
  39047. /**
  39048. * If entering vr was successful
  39049. */
  39050. success: boolean;
  39051. }
  39052. /**
  39053. * Helps to quickly add VR support to an existing scene.
  39054. * See http://doc.babylonjs.com/how_to/webvr_helper
  39055. */
  39056. export class VRExperienceHelper {
  39057. /** Options to modify the vr experience helper's behavior. */
  39058. webVROptions: VRExperienceHelperOptions;
  39059. private _scene;
  39060. private _position;
  39061. private _btnVR;
  39062. private _btnVRDisplayed;
  39063. private _webVRsupported;
  39064. private _webVRready;
  39065. private _webVRrequesting;
  39066. private _webVRpresenting;
  39067. private _hasEnteredVR;
  39068. private _fullscreenVRpresenting;
  39069. private _canvas;
  39070. private _webVRCamera;
  39071. private _vrDeviceOrientationCamera;
  39072. private _deviceOrientationCamera;
  39073. private _existingCamera;
  39074. private _onKeyDown;
  39075. private _onVrDisplayPresentChange;
  39076. private _onVRDisplayChanged;
  39077. private _onVRRequestPresentStart;
  39078. private _onVRRequestPresentComplete;
  39079. /**
  39080. * Observable raised right before entering VR.
  39081. */
  39082. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39083. /**
  39084. * Observable raised when entering VR has completed.
  39085. */
  39086. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39087. /**
  39088. * Observable raised when exiting VR.
  39089. */
  39090. onExitingVRObservable: Observable<VRExperienceHelper>;
  39091. /**
  39092. * Observable raised when controller mesh is loaded.
  39093. */
  39094. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39095. /** Return this.onEnteringVRObservable
  39096. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39097. */
  39098. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39099. /** Return this.onExitingVRObservable
  39100. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39101. */
  39102. readonly onExitingVR: Observable<VRExperienceHelper>;
  39103. /** Return this.onControllerMeshLoadedObservable
  39104. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39105. */
  39106. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39107. private _rayLength;
  39108. private _useCustomVRButton;
  39109. private _teleportationRequested;
  39110. private _teleportActive;
  39111. private _floorMeshName;
  39112. private _floorMeshesCollection;
  39113. private _rotationAllowed;
  39114. private _teleportBackwardsVector;
  39115. private _teleportationTarget;
  39116. private _isDefaultTeleportationTarget;
  39117. private _postProcessMove;
  39118. private _teleportationFillColor;
  39119. private _teleportationBorderColor;
  39120. private _rotationAngle;
  39121. private _haloCenter;
  39122. private _cameraGazer;
  39123. private _padSensibilityUp;
  39124. private _padSensibilityDown;
  39125. private _leftController;
  39126. private _rightController;
  39127. /**
  39128. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39129. */
  39130. onNewMeshSelected: Observable<AbstractMesh>;
  39131. /**
  39132. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39133. */
  39134. onNewMeshPicked: Observable<PickingInfo>;
  39135. private _circleEase;
  39136. /**
  39137. * Observable raised before camera teleportation
  39138. */
  39139. onBeforeCameraTeleport: Observable<Vector3>;
  39140. /**
  39141. * Observable raised after camera teleportation
  39142. */
  39143. onAfterCameraTeleport: Observable<Vector3>;
  39144. /**
  39145. * Observable raised when current selected mesh gets unselected
  39146. */
  39147. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39148. private _raySelectionPredicate;
  39149. /**
  39150. * To be optionaly changed by user to define custom ray selection
  39151. */
  39152. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39153. /**
  39154. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39155. */
  39156. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39157. /**
  39158. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39159. */
  39160. teleportationEnabled: boolean;
  39161. private _defaultHeight;
  39162. private _teleportationInitialized;
  39163. private _interactionsEnabled;
  39164. private _interactionsRequested;
  39165. private _displayGaze;
  39166. private _displayLaserPointer;
  39167. /**
  39168. * The mesh used to display where the user is going to teleport.
  39169. */
  39170. /**
  39171. * Sets the mesh to be used to display where the user is going to teleport.
  39172. */
  39173. teleportationTarget: Mesh;
  39174. /**
  39175. * 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
  39176. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39177. * See http://doc.babylonjs.com/resources/baking_transformations
  39178. */
  39179. gazeTrackerMesh: Mesh;
  39180. /**
  39181. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39182. */
  39183. updateGazeTrackerScale: boolean;
  39184. /**
  39185. * If the gaze trackers color should be updated when selecting meshes
  39186. */
  39187. updateGazeTrackerColor: boolean;
  39188. /**
  39189. * The gaze tracking mesh corresponding to the left controller
  39190. */
  39191. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39192. /**
  39193. * The gaze tracking mesh corresponding to the right controller
  39194. */
  39195. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39196. /**
  39197. * If the ray of the gaze should be displayed.
  39198. */
  39199. /**
  39200. * Sets if the ray of the gaze should be displayed.
  39201. */
  39202. displayGaze: boolean;
  39203. /**
  39204. * If the ray of the LaserPointer should be displayed.
  39205. */
  39206. /**
  39207. * Sets if the ray of the LaserPointer should be displayed.
  39208. */
  39209. displayLaserPointer: boolean;
  39210. /**
  39211. * The deviceOrientationCamera used as the camera when not in VR.
  39212. */
  39213. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39214. /**
  39215. * Based on the current WebVR support, returns the current VR camera used.
  39216. */
  39217. readonly currentVRCamera: Nullable<Camera>;
  39218. /**
  39219. * The webVRCamera which is used when in VR.
  39220. */
  39221. readonly webVRCamera: WebVRFreeCamera;
  39222. /**
  39223. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39224. */
  39225. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39226. private readonly _teleportationRequestInitiated;
  39227. /**
  39228. * Defines wether or not Pointer lock should be requested when switching to
  39229. * full screen.
  39230. */
  39231. requestPointerLockOnFullScreen: boolean;
  39232. /**
  39233. * Instantiates a VRExperienceHelper.
  39234. * Helps to quickly add VR support to an existing scene.
  39235. * @param scene The scene the VRExperienceHelper belongs to.
  39236. * @param webVROptions Options to modify the vr experience helper's behavior.
  39237. */
  39238. constructor(scene: Scene,
  39239. /** Options to modify the vr experience helper's behavior. */
  39240. webVROptions?: VRExperienceHelperOptions);
  39241. private _onDefaultMeshLoaded;
  39242. private _onResize;
  39243. private _onFullscreenChange;
  39244. /**
  39245. * Gets a value indicating if we are currently in VR mode.
  39246. */
  39247. readonly isInVRMode: boolean;
  39248. private onVrDisplayPresentChange;
  39249. private onVRDisplayChanged;
  39250. private moveButtonToBottomRight;
  39251. private displayVRButton;
  39252. private updateButtonVisibility;
  39253. private _cachedAngularSensibility;
  39254. /**
  39255. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39256. * Otherwise, will use the fullscreen API.
  39257. */
  39258. enterVR(): void;
  39259. /**
  39260. * Attempt to exit VR, or fullscreen.
  39261. */
  39262. exitVR(): void;
  39263. /**
  39264. * The position of the vr experience helper.
  39265. */
  39266. /**
  39267. * Sets the position of the vr experience helper.
  39268. */
  39269. position: Vector3;
  39270. /**
  39271. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39272. */
  39273. enableInteractions(): void;
  39274. private readonly _noControllerIsActive;
  39275. private beforeRender;
  39276. private _isTeleportationFloor;
  39277. /**
  39278. * Adds a floor mesh to be used for teleportation.
  39279. * @param floorMesh the mesh to be used for teleportation.
  39280. */
  39281. addFloorMesh(floorMesh: Mesh): void;
  39282. /**
  39283. * Removes a floor mesh from being used for teleportation.
  39284. * @param floorMesh the mesh to be removed.
  39285. */
  39286. removeFloorMesh(floorMesh: Mesh): void;
  39287. /**
  39288. * Enables interactions and teleportation using the VR controllers and gaze.
  39289. * @param vrTeleportationOptions options to modify teleportation behavior.
  39290. */
  39291. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39292. private _onNewGamepadConnected;
  39293. private _tryEnableInteractionOnController;
  39294. private _onNewGamepadDisconnected;
  39295. private _enableInteractionOnController;
  39296. private _checkTeleportWithRay;
  39297. private _checkRotate;
  39298. private _checkTeleportBackwards;
  39299. private _enableTeleportationOnController;
  39300. private _createTeleportationCircles;
  39301. private _displayTeleportationTarget;
  39302. private _hideTeleportationTarget;
  39303. private _rotateCamera;
  39304. private _moveTeleportationSelectorTo;
  39305. private _workingVector;
  39306. private _workingQuaternion;
  39307. private _workingMatrix;
  39308. /**
  39309. * Teleports the users feet to the desired location
  39310. * @param location The location where the user's feet should be placed
  39311. */
  39312. teleportCamera(location: Vector3): void;
  39313. private _convertNormalToDirectionOfRay;
  39314. private _castRayAndSelectObject;
  39315. private _notifySelectedMeshUnselected;
  39316. /**
  39317. * Sets the color of the laser ray from the vr controllers.
  39318. * @param color new color for the ray.
  39319. */
  39320. changeLaserColor(color: Color3): void;
  39321. /**
  39322. * Sets the color of the ray from the vr headsets gaze.
  39323. * @param color new color for the ray.
  39324. */
  39325. changeGazeColor(color: Color3): void;
  39326. /**
  39327. * Exits VR and disposes of the vr experience helper
  39328. */
  39329. dispose(): void;
  39330. /**
  39331. * Gets the name of the VRExperienceHelper class
  39332. * @returns "VRExperienceHelper"
  39333. */
  39334. getClassName(): string;
  39335. }
  39336. }
  39337. declare module BABYLON {
  39338. /**
  39339. * Manages an XRSession
  39340. * @see https://doc.babylonjs.com/how_to/webxr
  39341. */
  39342. export class WebXRSessionManager implements IDisposable {
  39343. private scene;
  39344. /**
  39345. * Fires every time a new xrFrame arrives which can be used to update the camera
  39346. */
  39347. onXRFrameObservable: Observable<any>;
  39348. /**
  39349. * Fires when the xr session is ended either by the device or manually done
  39350. */
  39351. onXRSessionEnded: Observable<any>;
  39352. /** @hidden */ private _xrSession: XRSession;
  39353. /** @hidden */ private _frameOfReference: XRFrameOfReference;
  39354. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39355. /** @hidden */ private _currentXRFrame: Nullable<XRFrame>;
  39356. private _xrNavigator;
  39357. private _xrDevice;
  39358. private _tmpMatrix;
  39359. /**
  39360. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39361. * @param scene The scene which the session should be created for
  39362. */
  39363. constructor(scene: Scene);
  39364. /**
  39365. * Initializes the manager
  39366. * After initialization enterXR can be called to start an XR session
  39367. * @returns Promise which resolves after it is initialized
  39368. */
  39369. initializeAsync(): Promise<void>;
  39370. /**
  39371. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39372. * @param sessionCreationOptions xr options to create the session with
  39373. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39374. * @returns Promise which resolves after it enters XR
  39375. */
  39376. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39377. /**
  39378. * Stops the xrSession and restores the renderloop
  39379. * @returns Promise which resolves after it exits XR
  39380. */
  39381. exitXRAsync(): Promise<void>;
  39382. /**
  39383. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39384. * @param ray ray to cast into the environment
  39385. * @returns Promise which resolves with a collision point in the environment if it exists
  39386. */
  39387. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39388. /**
  39389. * Checks if a session would be supported for the creation options specified
  39390. * @param options creation options to check if they are supported
  39391. * @returns true if supported
  39392. */
  39393. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39394. /**
  39395. * @hidden
  39396. * Converts the render layer of xrSession to a render target
  39397. * @param session session to create render target for
  39398. * @param scene scene the new render target should be created for
  39399. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39400. /**
  39401. * Disposes of the session manager
  39402. */
  39403. dispose(): void;
  39404. }
  39405. }
  39406. declare module BABYLON {
  39407. /**
  39408. * WebXR Camera which holds the views for the xrSession
  39409. * @see https://doc.babylonjs.com/how_to/webxr
  39410. */
  39411. export class WebXRCamera extends FreeCamera {
  39412. private static _TmpMatrix;
  39413. /**
  39414. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39415. * @param name the name of the camera
  39416. * @param scene the scene to add the camera to
  39417. */
  39418. constructor(name: string, scene: Scene);
  39419. private _updateNumberOfRigCameras;
  39420. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  39421. /**
  39422. * Updates the cameras position from the current pose information of the XR session
  39423. * @param xrSessionManager the session containing pose information
  39424. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39425. */
  39426. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39427. }
  39428. }
  39429. declare module BABYLON {
  39430. /**
  39431. * States of the webXR experience
  39432. */
  39433. export enum WebXRState {
  39434. /**
  39435. * Transitioning to being in XR mode
  39436. */
  39437. ENTERING_XR = 0,
  39438. /**
  39439. * Transitioning to non XR mode
  39440. */
  39441. EXITING_XR = 1,
  39442. /**
  39443. * In XR mode and presenting
  39444. */
  39445. IN_XR = 2,
  39446. /**
  39447. * Not entered XR mode
  39448. */
  39449. NOT_IN_XR = 3
  39450. }
  39451. /**
  39452. * Helper class used to enable XR
  39453. * @see https://doc.babylonjs.com/how_to/webxr
  39454. */
  39455. export class WebXRExperienceHelper implements IDisposable {
  39456. private scene;
  39457. /**
  39458. * 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
  39459. */
  39460. container: AbstractMesh;
  39461. /**
  39462. * Camera used to render xr content
  39463. */
  39464. camera: WebXRCamera;
  39465. /**
  39466. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39467. */
  39468. state: WebXRState;
  39469. private _setState;
  39470. private static _TmpVector;
  39471. /**
  39472. * Fires when the state of the experience helper has changed
  39473. */
  39474. onStateChangedObservable: Observable<WebXRState>;
  39475. /** @hidden */ private _sessionManager: WebXRSessionManager;
  39476. private _nonVRCamera;
  39477. private _originalSceneAutoClear;
  39478. private _supported;
  39479. /**
  39480. * Creates the experience helper
  39481. * @param scene the scene to attach the experience helper to
  39482. * @returns a promise for the experience helper
  39483. */
  39484. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39485. /**
  39486. * Creates a WebXRExperienceHelper
  39487. * @param scene The scene the helper should be created in
  39488. */
  39489. private constructor();
  39490. /**
  39491. * Exits XR mode and returns the scene to its original state
  39492. * @returns promise that resolves after xr mode has exited
  39493. */
  39494. exitXRAsync(): Promise<void>;
  39495. /**
  39496. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39497. * @param sessionCreationOptions options for the XR session
  39498. * @param frameOfReference frame of reference of the XR session
  39499. * @returns promise that resolves after xr mode has entered
  39500. */
  39501. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39502. /**
  39503. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39504. * @param ray ray to cast into the environment
  39505. * @returns Promise which resolves with a collision point in the environment if it exists
  39506. */
  39507. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39508. /**
  39509. * Updates the global position of the camera by moving the camera's container
  39510. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39511. * @param position The desired global position of the camera
  39512. */
  39513. setPositionOfCameraUsingContainer(position: Vector3): void;
  39514. /**
  39515. * Rotates the xr camera by rotating the camera's container around the camera's position
  39516. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39517. * @param rotation the desired quaternion rotation to apply to the camera
  39518. */
  39519. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39520. /**
  39521. * Checks if the creation options are supported by the xr session
  39522. * @param options creation options
  39523. * @returns true if supported
  39524. */
  39525. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39526. /**
  39527. * Disposes of the experience helper
  39528. */
  39529. dispose(): void;
  39530. }
  39531. }
  39532. declare module BABYLON {
  39533. /**
  39534. * Button which can be used to enter a different mode of XR
  39535. */
  39536. export class WebXREnterExitUIButton {
  39537. /** button element */
  39538. element: HTMLElement;
  39539. /** XR initialization options for the button */
  39540. initializationOptions: XRSessionCreationOptions;
  39541. /**
  39542. * Creates a WebXREnterExitUIButton
  39543. * @param element button element
  39544. * @param initializationOptions XR initialization options for the button
  39545. */
  39546. constructor(
  39547. /** button element */
  39548. element: HTMLElement,
  39549. /** XR initialization options for the button */
  39550. initializationOptions: XRSessionCreationOptions);
  39551. /**
  39552. * Overwritable function which can be used to update the button's visuals when the state changes
  39553. * @param activeButton the current active button in the UI
  39554. */
  39555. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39556. }
  39557. /**
  39558. * Options to create the webXR UI
  39559. */
  39560. export class WebXREnterExitUIOptions {
  39561. /**
  39562. * Context to enter xr with
  39563. */
  39564. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39565. /**
  39566. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39567. */
  39568. customButtons?: Array<WebXREnterExitUIButton>;
  39569. }
  39570. /**
  39571. * UI to allow the user to enter/exit XR mode
  39572. */
  39573. export class WebXREnterExitUI implements IDisposable {
  39574. private scene;
  39575. private _overlay;
  39576. private _buttons;
  39577. private _activeButton;
  39578. /**
  39579. * Fired every time the active button is changed.
  39580. *
  39581. * When xr is entered via a button that launches xr that button will be the callback parameter
  39582. *
  39583. * When exiting xr the callback parameter will be null)
  39584. */
  39585. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39586. /**
  39587. * Creates UI to allow the user to enter/exit XR mode
  39588. * @param scene the scene to add the ui to
  39589. * @param helper the xr experience helper to enter/exit xr with
  39590. * @param options options to configure the UI
  39591. * @returns the created ui
  39592. */
  39593. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39594. private constructor();
  39595. private _updateButtons;
  39596. /**
  39597. * Disposes of the object
  39598. */
  39599. dispose(): void;
  39600. }
  39601. }
  39602. declare module BABYLON {
  39603. /**
  39604. * Represents an XR input
  39605. */
  39606. export class WebXRController {
  39607. /**
  39608. * 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
  39609. */
  39610. grip?: AbstractMesh;
  39611. /**
  39612. * Pointer which can be used to select objects or attach a visible laser to
  39613. */
  39614. pointer: AbstractMesh;
  39615. /**
  39616. * Creates the controller
  39617. * @see https://doc.babylonjs.com/how_to/webxr
  39618. * @param scene the scene which the controller should be associated to
  39619. */
  39620. constructor(scene: Scene);
  39621. /**
  39622. * Disposes of the object
  39623. */
  39624. dispose(): void;
  39625. }
  39626. /**
  39627. * XR input used to track XR inputs such as controllers/rays
  39628. */
  39629. export class WebXRInput implements IDisposable {
  39630. private helper;
  39631. /**
  39632. * XR controllers being tracked
  39633. */
  39634. controllers: Array<WebXRController>;
  39635. private _tmpMatrix;
  39636. private _frameObserver;
  39637. /**
  39638. * Initializes the WebXRInput
  39639. * @param helper experience helper which the input should be created for
  39640. */
  39641. constructor(helper: WebXRExperienceHelper);
  39642. /**
  39643. * Disposes of the object
  39644. */
  39645. dispose(): void;
  39646. }
  39647. }
  39648. declare module BABYLON {
  39649. /**
  39650. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39651. */
  39652. export class WebXRManagedOutputCanvas implements IDisposable {
  39653. private _canvas;
  39654. /**
  39655. * xrpresent context of the canvas which can be used to display/mirror xr content
  39656. */
  39657. canvasContext: Nullable<WebGLRenderingContext>;
  39658. /**
  39659. * Initializes the canvas to be added/removed upon entering/exiting xr
  39660. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39661. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39662. */
  39663. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39664. /**
  39665. * Disposes of the object
  39666. */
  39667. dispose(): void;
  39668. private _setManagedOutputCanvas;
  39669. private _addCanvas;
  39670. private _removeCanvas;
  39671. }
  39672. }
  39673. declare module BABYLON {
  39674. /**
  39675. * Contains an array of blocks representing the octree
  39676. */
  39677. export interface IOctreeContainer<T> {
  39678. /**
  39679. * Blocks within the octree
  39680. */
  39681. blocks: Array<OctreeBlock<T>>;
  39682. }
  39683. /**
  39684. * Class used to store a cell in an octree
  39685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39686. */
  39687. export class OctreeBlock<T> {
  39688. /**
  39689. * Gets the content of the current block
  39690. */
  39691. entries: T[];
  39692. /**
  39693. * Gets the list of block children
  39694. */
  39695. blocks: Array<OctreeBlock<T>>;
  39696. private _depth;
  39697. private _maxDepth;
  39698. private _capacity;
  39699. private _minPoint;
  39700. private _maxPoint;
  39701. private _boundingVectors;
  39702. private _creationFunc;
  39703. /**
  39704. * Creates a new block
  39705. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39706. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39707. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39708. * @param depth defines the current depth of this block in the octree
  39709. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39710. * @param creationFunc defines a callback to call when an element is added to the block
  39711. */
  39712. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39713. /**
  39714. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39715. */
  39716. readonly capacity: number;
  39717. /**
  39718. * Gets the minimum vector (in world space) of the block's bounding box
  39719. */
  39720. readonly minPoint: Vector3;
  39721. /**
  39722. * Gets the maximum vector (in world space) of the block's bounding box
  39723. */
  39724. readonly maxPoint: Vector3;
  39725. /**
  39726. * Add a new element to this block
  39727. * @param entry defines the element to add
  39728. */
  39729. addEntry(entry: T): void;
  39730. /**
  39731. * Remove an element from this block
  39732. * @param entry defines the element to remove
  39733. */
  39734. removeEntry(entry: T): void;
  39735. /**
  39736. * Add an array of elements to this block
  39737. * @param entries defines the array of elements to add
  39738. */
  39739. addEntries(entries: T[]): void;
  39740. /**
  39741. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39742. * @param frustumPlanes defines the frustum planes to test
  39743. * @param selection defines the array to store current content if selection is positive
  39744. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39745. */
  39746. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39747. /**
  39748. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39749. * @param sphereCenter defines the bounding sphere center
  39750. * @param sphereRadius defines the bounding sphere radius
  39751. * @param selection defines the array to store current content if selection is positive
  39752. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39753. */
  39754. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39755. /**
  39756. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39757. * @param ray defines the ray to test with
  39758. * @param selection defines the array to store current content if selection is positive
  39759. */
  39760. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39761. /**
  39762. * Subdivide the content into child blocks (this block will then be empty)
  39763. */
  39764. createInnerBlocks(): void;
  39765. /**
  39766. * @hidden
  39767. */ 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;
  39768. }
  39769. }
  39770. declare module BABYLON {
  39771. /**
  39772. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39774. */
  39775. export class Octree<T> {
  39776. /** 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.) */
  39777. maxDepth: number;
  39778. /**
  39779. * Blocks within the octree containing objects
  39780. */
  39781. blocks: Array<OctreeBlock<T>>;
  39782. /**
  39783. * Content stored in the octree
  39784. */
  39785. dynamicContent: T[];
  39786. private _maxBlockCapacity;
  39787. private _selectionContent;
  39788. private _creationFunc;
  39789. /**
  39790. * Creates a octree
  39791. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39792. * @param creationFunc function to be used to instatiate the octree
  39793. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39794. * @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.)
  39795. */
  39796. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39797. /** 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.) */
  39798. maxDepth?: number);
  39799. /**
  39800. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39801. * @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);
  39802. * @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);
  39803. * @param entries meshes to be added to the octree blocks
  39804. */
  39805. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39806. /**
  39807. * Adds a mesh to the octree
  39808. * @param entry Mesh to add to the octree
  39809. */
  39810. addMesh(entry: T): void;
  39811. /**
  39812. * Remove an element from the octree
  39813. * @param entry defines the element to remove
  39814. */
  39815. removeMesh(entry: T): void;
  39816. /**
  39817. * Selects an array of meshes within the frustum
  39818. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39819. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39820. * @returns array of meshes within the frustum
  39821. */
  39822. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39823. /**
  39824. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39825. * @param sphereCenter defines the bounding sphere center
  39826. * @param sphereRadius defines the bounding sphere radius
  39827. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39828. * @returns an array of objects that intersect the sphere
  39829. */
  39830. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39831. /**
  39832. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39833. * @param ray defines the ray to test with
  39834. * @returns array of intersected objects
  39835. */
  39836. intersectsRay(ray: Ray): SmartArray<T>;
  39837. /**
  39838. * Adds a mesh into the octree block if it intersects the block
  39839. */
  39840. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39841. /**
  39842. * Adds a submesh into the octree block if it intersects the block
  39843. */
  39844. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39845. }
  39846. }
  39847. declare module BABYLON {
  39848. interface Scene {
  39849. /**
  39850. * @hidden
  39851. * Backing Filed
  39852. */ private _selectionOctree: Octree<AbstractMesh>;
  39853. /**
  39854. * Gets the octree used to boost mesh selection (picking)
  39855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39856. */
  39857. selectionOctree: Octree<AbstractMesh>;
  39858. /**
  39859. * Creates or updates the octree used to boost selection (picking)
  39860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39861. * @param maxCapacity defines the maximum capacity per leaf
  39862. * @param maxDepth defines the maximum depth of the octree
  39863. * @returns an octree of AbstractMesh
  39864. */
  39865. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39866. }
  39867. interface AbstractMesh {
  39868. /**
  39869. * @hidden
  39870. * Backing Field
  39871. */ private _submeshesOctree: Octree<SubMesh>;
  39872. /**
  39873. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39874. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39875. * @param maxCapacity defines the maximum size of each block (64 by default)
  39876. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39877. * @returns the new octree
  39878. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39880. */
  39881. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39882. }
  39883. /**
  39884. * Defines the octree scene component responsible to manage any octrees
  39885. * in a given scene.
  39886. */
  39887. export class OctreeSceneComponent {
  39888. /**
  39889. * The component name help to identify the component in the list of scene components.
  39890. */
  39891. readonly name: string;
  39892. /**
  39893. * The scene the component belongs to.
  39894. */
  39895. scene: Scene;
  39896. /**
  39897. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39898. */
  39899. readonly checksIsEnabled: boolean;
  39900. /**
  39901. * Creates a new instance of the component for the given scene
  39902. * @param scene Defines the scene to register the component in
  39903. */
  39904. constructor(scene: Scene);
  39905. /**
  39906. * Registers the component in a given scene
  39907. */
  39908. register(): void;
  39909. /**
  39910. * Return the list of active meshes
  39911. * @returns the list of active meshes
  39912. */
  39913. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39914. /**
  39915. * Return the list of active sub meshes
  39916. * @param mesh The mesh to get the candidates sub meshes from
  39917. * @returns the list of active sub meshes
  39918. */
  39919. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39920. private _tempRay;
  39921. /**
  39922. * Return the list of sub meshes intersecting with a given local ray
  39923. * @param mesh defines the mesh to find the submesh for
  39924. * @param localRay defines the ray in local space
  39925. * @returns the list of intersecting sub meshes
  39926. */
  39927. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39928. /**
  39929. * Return the list of sub meshes colliding with a collider
  39930. * @param mesh defines the mesh to find the submesh for
  39931. * @param collider defines the collider to evaluate the collision against
  39932. * @returns the list of colliding sub meshes
  39933. */
  39934. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39935. /**
  39936. * Rebuilds the elements related to this component in case of
  39937. * context lost for instance.
  39938. */
  39939. rebuild(): void;
  39940. /**
  39941. * Disposes the component and the associated ressources.
  39942. */
  39943. dispose(): void;
  39944. }
  39945. }
  39946. declare module BABYLON {
  39947. /**
  39948. * Renders a layer on top of an existing scene
  39949. */
  39950. export class UtilityLayerRenderer implements IDisposable {
  39951. /** the original scene that will be rendered on top of */
  39952. originalScene: Scene;
  39953. private _pointerCaptures;
  39954. private _lastPointerEvents;
  39955. private static _DefaultUtilityLayer;
  39956. private static _DefaultKeepDepthUtilityLayer;
  39957. private _sharedGizmoLight;
  39958. /**
  39959. * @hidden
  39960. * Light which used by gizmos to get light shading
  39961. */ private _getSharedGizmoLight(): HemisphericLight;
  39962. /**
  39963. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39964. */
  39965. pickUtilitySceneFirst: boolean;
  39966. /**
  39967. * 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)
  39968. */
  39969. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39970. /**
  39971. * 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)
  39972. */
  39973. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39974. /**
  39975. * The scene that is rendered on top of the original scene
  39976. */
  39977. utilityLayerScene: Scene;
  39978. /**
  39979. * If the utility layer should automatically be rendered on top of existing scene
  39980. */
  39981. shouldRender: boolean;
  39982. /**
  39983. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39984. */
  39985. onlyCheckPointerDownEvents: boolean;
  39986. /**
  39987. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39988. */
  39989. processAllEvents: boolean;
  39990. /**
  39991. * Observable raised when the pointer move from the utility layer scene to the main scene
  39992. */
  39993. onPointerOutObservable: Observable<number>;
  39994. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39995. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39996. private _afterRenderObserver;
  39997. private _sceneDisposeObserver;
  39998. private _originalPointerObserver;
  39999. /**
  40000. * Instantiates a UtilityLayerRenderer
  40001. * @param originalScene the original scene that will be rendered on top of
  40002. * @param handleEvents boolean indicating if the utility layer should handle events
  40003. */
  40004. constructor(
  40005. /** the original scene that will be rendered on top of */
  40006. originalScene: Scene, handleEvents?: boolean);
  40007. private _notifyObservers;
  40008. /**
  40009. * Renders the utility layers scene on top of the original scene
  40010. */
  40011. render(): void;
  40012. /**
  40013. * Disposes of the renderer
  40014. */
  40015. dispose(): void;
  40016. private _updateCamera;
  40017. }
  40018. }
  40019. declare module BABYLON {
  40020. /**
  40021. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40022. */
  40023. export class Gizmo implements IDisposable {
  40024. /** The utility layer the gizmo will be added to */
  40025. gizmoLayer: UtilityLayerRenderer;
  40026. /**
  40027. * The root mesh of the gizmo
  40028. */ private _rootMesh: Mesh;
  40029. private _attachedMesh;
  40030. /**
  40031. * Ratio for the scale of the gizmo (Default: 1)
  40032. */
  40033. scaleRatio: number;
  40034. /**
  40035. * If a custom mesh has been set (Default: false)
  40036. */
  40037. protected _customMeshSet: boolean;
  40038. /**
  40039. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40040. * * When set, interactions will be enabled
  40041. */
  40042. attachedMesh: Nullable<AbstractMesh>;
  40043. /**
  40044. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40045. * @param mesh The mesh to replace the default mesh of the gizmo
  40046. */
  40047. setCustomMesh(mesh: Mesh): void;
  40048. /**
  40049. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40050. */
  40051. updateGizmoRotationToMatchAttachedMesh: boolean;
  40052. /**
  40053. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40054. */
  40055. updateGizmoPositionToMatchAttachedMesh: boolean;
  40056. /**
  40057. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40058. */
  40059. protected _updateScale: boolean;
  40060. protected _interactionsEnabled: boolean;
  40061. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40062. private _beforeRenderObserver;
  40063. private _tempVector;
  40064. /**
  40065. * Creates a gizmo
  40066. * @param gizmoLayer The utility layer the gizmo will be added to
  40067. */
  40068. constructor(
  40069. /** The utility layer the gizmo will be added to */
  40070. gizmoLayer?: UtilityLayerRenderer);
  40071. /**
  40072. * Updates the gizmo to match the attached mesh's position/rotation
  40073. */
  40074. protected _update(): void;
  40075. /**
  40076. * Disposes of the gizmo
  40077. */
  40078. dispose(): void;
  40079. }
  40080. }
  40081. declare module BABYLON {
  40082. /**
  40083. * Single axis drag gizmo
  40084. */
  40085. export class AxisDragGizmo extends Gizmo {
  40086. /**
  40087. * Drag behavior responsible for the gizmos dragging interactions
  40088. */
  40089. dragBehavior: PointerDragBehavior;
  40090. private _pointerObserver;
  40091. /**
  40092. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40093. */
  40094. snapDistance: number;
  40095. /**
  40096. * Event that fires each time the gizmo snaps to a new location.
  40097. * * snapDistance is the the change in distance
  40098. */
  40099. onSnapObservable: Observable<{
  40100. snapDistance: number;
  40101. }>;
  40102. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40103. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40104. /**
  40105. * Creates an AxisDragGizmo
  40106. * @param gizmoLayer The utility layer the gizmo will be added to
  40107. * @param dragAxis The axis which the gizmo will be able to drag on
  40108. * @param color The color of the gizmo
  40109. */
  40110. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40111. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40112. /**
  40113. * Disposes of the gizmo
  40114. */
  40115. dispose(): void;
  40116. }
  40117. }
  40118. declare module BABYLON.Debug {
  40119. /**
  40120. * The Axes viewer will show 3 axes in a specific point in space
  40121. */
  40122. export class AxesViewer {
  40123. private _xAxis;
  40124. private _yAxis;
  40125. private _zAxis;
  40126. private _scaleLinesFactor;
  40127. private _instanced;
  40128. /**
  40129. * Gets the hosting scene
  40130. */
  40131. scene: Scene;
  40132. /**
  40133. * Gets or sets a number used to scale line length
  40134. */
  40135. scaleLines: number;
  40136. /** Gets the node hierarchy used to render x-axis */
  40137. readonly xAxis: TransformNode;
  40138. /** Gets the node hierarchy used to render y-axis */
  40139. readonly yAxis: TransformNode;
  40140. /** Gets the node hierarchy used to render z-axis */
  40141. readonly zAxis: TransformNode;
  40142. /**
  40143. * Creates a new AxesViewer
  40144. * @param scene defines the hosting scene
  40145. * @param scaleLines defines a number used to scale line length (1 by default)
  40146. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40147. * @param xAxis defines the node hierarchy used to render the x-axis
  40148. * @param yAxis defines the node hierarchy used to render the y-axis
  40149. * @param zAxis defines the node hierarchy used to render the z-axis
  40150. */
  40151. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40152. /**
  40153. * Force the viewer to update
  40154. * @param position defines the position of the viewer
  40155. * @param xaxis defines the x axis of the viewer
  40156. * @param yaxis defines the y axis of the viewer
  40157. * @param zaxis defines the z axis of the viewer
  40158. */
  40159. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40160. /**
  40161. * Creates an instance of this axes viewer.
  40162. * @returns a new axes viewer with instanced meshes
  40163. */
  40164. createInstance(): AxesViewer;
  40165. /** Releases resources */
  40166. dispose(): void;
  40167. private static _SetRenderingGroupId;
  40168. }
  40169. }
  40170. declare module BABYLON.Debug {
  40171. /**
  40172. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40173. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40174. */
  40175. export class BoneAxesViewer extends AxesViewer {
  40176. /**
  40177. * Gets or sets the target mesh where to display the axes viewer
  40178. */
  40179. mesh: Nullable<Mesh>;
  40180. /**
  40181. * Gets or sets the target bone where to display the axes viewer
  40182. */
  40183. bone: Nullable<Bone>;
  40184. /** Gets current position */
  40185. pos: Vector3;
  40186. /** Gets direction of X axis */
  40187. xaxis: Vector3;
  40188. /** Gets direction of Y axis */
  40189. yaxis: Vector3;
  40190. /** Gets direction of Z axis */
  40191. zaxis: Vector3;
  40192. /**
  40193. * Creates a new BoneAxesViewer
  40194. * @param scene defines the hosting scene
  40195. * @param bone defines the target bone
  40196. * @param mesh defines the target mesh
  40197. * @param scaleLines defines a scaling factor for line length (1 by default)
  40198. */
  40199. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40200. /**
  40201. * Force the viewer to update
  40202. */
  40203. update(): void;
  40204. /** Releases resources */
  40205. dispose(): void;
  40206. }
  40207. }
  40208. declare module BABYLON {
  40209. /**
  40210. * Interface used to define scene explorer extensibility option
  40211. */
  40212. export interface IExplorerExtensibilityOption {
  40213. /**
  40214. * Define the option label
  40215. */
  40216. label: string;
  40217. /**
  40218. * Defines the action to execute on click
  40219. */
  40220. action: (entity: any) => void;
  40221. }
  40222. /**
  40223. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40224. */
  40225. export interface IExplorerExtensibilityGroup {
  40226. /**
  40227. * Defines a predicate to test if a given type mut be extended
  40228. */
  40229. predicate: (entity: any) => boolean;
  40230. /**
  40231. * Gets the list of options added to a type
  40232. */
  40233. entries: IExplorerExtensibilityOption[];
  40234. }
  40235. /**
  40236. * Interface used to define the options to use to create the Inspector
  40237. */
  40238. export interface IInspectorOptions {
  40239. /**
  40240. * Display in overlay mode (default: false)
  40241. */
  40242. overlay?: boolean;
  40243. /**
  40244. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40245. */
  40246. globalRoot?: HTMLElement;
  40247. /**
  40248. * Display the Scene explorer
  40249. */
  40250. showExplorer?: boolean;
  40251. /**
  40252. * Display the property inspector
  40253. */
  40254. showInspector?: boolean;
  40255. /**
  40256. * Display in embed mode (both panes on the right)
  40257. */
  40258. embedMode?: boolean;
  40259. /**
  40260. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40261. */
  40262. handleResize?: boolean;
  40263. /**
  40264. * Allow the panes to popup (default: true)
  40265. */
  40266. enablePopup?: boolean;
  40267. /**
  40268. * Allow the panes to be closed by users (default: true)
  40269. */
  40270. enableClose?: boolean;
  40271. /**
  40272. * Optional list of extensibility entries
  40273. */
  40274. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40275. /**
  40276. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40277. */
  40278. inspectorURL?: string;
  40279. }
  40280. interface Scene {
  40281. /**
  40282. * @hidden
  40283. * Backing field
  40284. */ private _debugLayer: DebugLayer;
  40285. /**
  40286. * Gets the debug layer (aka Inspector) associated with the scene
  40287. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40288. */
  40289. debugLayer: DebugLayer;
  40290. }
  40291. /**
  40292. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40293. * what is happening in your scene
  40294. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40295. */
  40296. export class DebugLayer {
  40297. /**
  40298. * Define the url to get the inspector script from.
  40299. * By default it uses the babylonjs CDN.
  40300. * @ignoreNaming
  40301. */
  40302. static InspectorURL: string;
  40303. private _scene;
  40304. private BJSINSPECTOR;
  40305. /**
  40306. * Observable triggered when a property is changed through the inspector.
  40307. */
  40308. onPropertyChangedObservable: Observable<{
  40309. object: any;
  40310. property: string;
  40311. value: any;
  40312. initialValue: any;
  40313. }>;
  40314. /**
  40315. * Instantiates a new debug layer.
  40316. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40317. * what is happening in your scene
  40318. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40319. * @param scene Defines the scene to inspect
  40320. */
  40321. constructor(scene: Scene);
  40322. /** Creates the inspector window. */
  40323. private _createInspector;
  40324. /**
  40325. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40326. * @param entity defines the entity to select
  40327. * @param lineContainerTitle defines the specific block to highlight
  40328. */
  40329. select(entity: any, lineContainerTitle?: string): void;
  40330. /** Get the inspector from bundle or global */
  40331. private _getGlobalInspector;
  40332. /**
  40333. * Get if the inspector is visible or not.
  40334. * @returns true if visible otherwise, false
  40335. */
  40336. isVisible(): boolean;
  40337. /**
  40338. * Hide the inspector and close its window.
  40339. */
  40340. hide(): void;
  40341. /**
  40342. * Launch the debugLayer.
  40343. * @param config Define the configuration of the inspector
  40344. * @return a promise fulfilled when the debug layer is visible
  40345. */
  40346. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40347. }
  40348. }
  40349. declare module BABYLON {
  40350. /**
  40351. * Class containing static functions to help procedurally build meshes
  40352. */
  40353. export class BoxBuilder {
  40354. /**
  40355. * Creates a box mesh
  40356. * * The parameter `size` sets the size (float) of each box side (default 1)
  40357. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40358. * * 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)
  40359. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40361. * * 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
  40362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40363. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40364. * @param name defines the name of the mesh
  40365. * @param options defines the options used to create the mesh
  40366. * @param scene defines the hosting scene
  40367. * @returns the box mesh
  40368. */
  40369. static CreateBox(name: string, options: {
  40370. size?: number;
  40371. width?: number;
  40372. height?: number;
  40373. depth?: number;
  40374. faceUV?: Vector4[];
  40375. faceColors?: Color4[];
  40376. sideOrientation?: number;
  40377. frontUVs?: Vector4;
  40378. backUVs?: Vector4;
  40379. wrap?: boolean;
  40380. topBaseAt?: number;
  40381. bottomBaseAt?: number;
  40382. updatable?: boolean;
  40383. }, scene?: Nullable<Scene>): Mesh;
  40384. }
  40385. }
  40386. declare module BABYLON {
  40387. /**
  40388. * Class containing static functions to help procedurally build meshes
  40389. */
  40390. export class SphereBuilder {
  40391. /**
  40392. * Creates a sphere mesh
  40393. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40394. * * 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`)
  40395. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40396. * * 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
  40397. * * 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)
  40398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40399. * * 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
  40400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40401. * @param name defines the name of the mesh
  40402. * @param options defines the options used to create the mesh
  40403. * @param scene defines the hosting scene
  40404. * @returns the sphere mesh
  40405. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40406. */
  40407. static CreateSphere(name: string, options: {
  40408. segments?: number;
  40409. diameter?: number;
  40410. diameterX?: number;
  40411. diameterY?: number;
  40412. diameterZ?: number;
  40413. arc?: number;
  40414. slice?: number;
  40415. sideOrientation?: number;
  40416. frontUVs?: Vector4;
  40417. backUVs?: Vector4;
  40418. updatable?: boolean;
  40419. }, scene: any): Mesh;
  40420. }
  40421. }
  40422. declare module BABYLON.Debug {
  40423. /**
  40424. * Used to show the physics impostor around the specific mesh
  40425. */
  40426. export class PhysicsViewer {
  40427. /** @hidden */
  40428. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40429. /** @hidden */
  40430. protected _meshes: Array<Nullable<AbstractMesh>>;
  40431. /** @hidden */
  40432. protected _scene: Nullable<Scene>;
  40433. /** @hidden */
  40434. protected _numMeshes: number;
  40435. /** @hidden */
  40436. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40437. private _renderFunction;
  40438. private _utilityLayer;
  40439. private _debugBoxMesh;
  40440. private _debugSphereMesh;
  40441. private _debugCylinderMesh;
  40442. private _debugMaterial;
  40443. private _debugMeshMeshes;
  40444. /**
  40445. * Creates a new PhysicsViewer
  40446. * @param scene defines the hosting scene
  40447. */
  40448. constructor(scene: Scene);
  40449. /** @hidden */
  40450. protected _updateDebugMeshes(): void;
  40451. /**
  40452. * Renders a specified physic impostor
  40453. * @param impostor defines the impostor to render
  40454. * @param targetMesh defines the mesh represented by the impostor
  40455. * @returns the new debug mesh used to render the impostor
  40456. */
  40457. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40458. /**
  40459. * Hides a specified physic impostor
  40460. * @param impostor defines the impostor to hide
  40461. */
  40462. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40463. private _getDebugMaterial;
  40464. private _getDebugBoxMesh;
  40465. private _getDebugSphereMesh;
  40466. private _getDebugCylinderMesh;
  40467. private _getDebugMeshMesh;
  40468. private _getDebugMesh;
  40469. /** Releases all resources */
  40470. dispose(): void;
  40471. }
  40472. }
  40473. declare module BABYLON {
  40474. /**
  40475. * Class containing static functions to help procedurally build meshes
  40476. */
  40477. export class LinesBuilder {
  40478. /**
  40479. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40480. * * 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
  40481. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40482. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40483. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40484. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40485. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40486. * * 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
  40487. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40490. * @param name defines the name of the new line system
  40491. * @param options defines the options used to create the line system
  40492. * @param scene defines the hosting scene
  40493. * @returns a new line system mesh
  40494. */
  40495. static CreateLineSystem(name: string, options: {
  40496. lines: Vector3[][];
  40497. updatable?: boolean;
  40498. instance?: Nullable<LinesMesh>;
  40499. colors?: Nullable<Color4[][]>;
  40500. useVertexAlpha?: boolean;
  40501. }, scene: Nullable<Scene>): LinesMesh;
  40502. /**
  40503. * Creates a line mesh
  40504. * 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
  40505. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40506. * * The parameter `points` is an array successive Vector3
  40507. * * 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
  40508. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40509. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40510. * * When updating an instance, remember that only point positions can change, not the number of points
  40511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40513. * @param name defines the name of the new line system
  40514. * @param options defines the options used to create the line system
  40515. * @param scene defines the hosting scene
  40516. * @returns a new line mesh
  40517. */
  40518. static CreateLines(name: string, options: {
  40519. points: Vector3[];
  40520. updatable?: boolean;
  40521. instance?: Nullable<LinesMesh>;
  40522. colors?: Color4[];
  40523. useVertexAlpha?: boolean;
  40524. }, scene?: Nullable<Scene>): LinesMesh;
  40525. /**
  40526. * Creates a dashed line mesh
  40527. * * 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
  40528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40529. * * The parameter `points` is an array successive Vector3
  40530. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40531. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40532. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40533. * * 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
  40534. * * When updating an instance, remember that only point positions can change, not the number of points
  40535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40536. * @param name defines the name of the mesh
  40537. * @param options defines the options used to create the mesh
  40538. * @param scene defines the hosting scene
  40539. * @returns the dashed line mesh
  40540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40541. */
  40542. static CreateDashedLines(name: string, options: {
  40543. points: Vector3[];
  40544. dashSize?: number;
  40545. gapSize?: number;
  40546. dashNb?: number;
  40547. updatable?: boolean;
  40548. instance?: LinesMesh;
  40549. }, scene?: Nullable<Scene>): LinesMesh;
  40550. }
  40551. }
  40552. declare module BABYLON {
  40553. /**
  40554. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40555. * in order to better appreciate the issue one might have.
  40556. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40557. */
  40558. export class RayHelper {
  40559. /**
  40560. * Defines the ray we are currently tryin to visualize.
  40561. */
  40562. ray: Nullable<Ray>;
  40563. private _renderPoints;
  40564. private _renderLine;
  40565. private _renderFunction;
  40566. private _scene;
  40567. private _updateToMeshFunction;
  40568. private _attachedToMesh;
  40569. private _meshSpaceDirection;
  40570. private _meshSpaceOrigin;
  40571. /**
  40572. * Helper function to create a colored helper in a scene in one line.
  40573. * @param ray Defines the ray we are currently tryin to visualize
  40574. * @param scene Defines the scene the ray is used in
  40575. * @param color Defines the color we want to see the ray in
  40576. * @returns The newly created ray helper.
  40577. */
  40578. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40579. /**
  40580. * Instantiate a new ray helper.
  40581. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40582. * in order to better appreciate the issue one might have.
  40583. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40584. * @param ray Defines the ray we are currently tryin to visualize
  40585. */
  40586. constructor(ray: Ray);
  40587. /**
  40588. * Shows the ray we are willing to debug.
  40589. * @param scene Defines the scene the ray needs to be rendered in
  40590. * @param color Defines the color the ray needs to be rendered in
  40591. */
  40592. show(scene: Scene, color?: Color3): void;
  40593. /**
  40594. * Hides the ray we are debugging.
  40595. */
  40596. hide(): void;
  40597. private _render;
  40598. /**
  40599. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40600. * @param mesh Defines the mesh we want the helper attached to
  40601. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40602. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40603. * @param length Defines the length of the ray
  40604. */
  40605. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40606. /**
  40607. * Detach the ray helper from the mesh it has previously been attached to.
  40608. */
  40609. detachFromMesh(): void;
  40610. private _updateToMesh;
  40611. /**
  40612. * Dispose the helper and release its associated resources.
  40613. */
  40614. dispose(): void;
  40615. }
  40616. }
  40617. declare module BABYLON.Debug {
  40618. /**
  40619. * Class used to render a debug view of a given skeleton
  40620. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40621. */
  40622. export class SkeletonViewer {
  40623. /** defines the skeleton to render */
  40624. skeleton: Skeleton;
  40625. /** defines the mesh attached to the skeleton */
  40626. mesh: AbstractMesh;
  40627. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40628. autoUpdateBonesMatrices: boolean;
  40629. /** defines the rendering group id to use with the viewer */
  40630. renderingGroupId: number;
  40631. /** Gets or sets the color used to render the skeleton */
  40632. color: Color3;
  40633. private _scene;
  40634. private _debugLines;
  40635. private _debugMesh;
  40636. private _isEnabled;
  40637. private _renderFunction;
  40638. private _utilityLayer;
  40639. /**
  40640. * Returns the mesh used to render the bones
  40641. */
  40642. readonly debugMesh: Nullable<LinesMesh>;
  40643. /**
  40644. * Creates a new SkeletonViewer
  40645. * @param skeleton defines the skeleton to render
  40646. * @param mesh defines the mesh attached to the skeleton
  40647. * @param scene defines the hosting scene
  40648. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40649. * @param renderingGroupId defines the rendering group id to use with the viewer
  40650. */
  40651. constructor(
  40652. /** defines the skeleton to render */
  40653. skeleton: Skeleton,
  40654. /** defines the mesh attached to the skeleton */
  40655. mesh: AbstractMesh, scene: Scene,
  40656. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40657. autoUpdateBonesMatrices?: boolean,
  40658. /** defines the rendering group id to use with the viewer */
  40659. renderingGroupId?: number);
  40660. /** Gets or sets a boolean indicating if the viewer is enabled */
  40661. isEnabled: boolean;
  40662. private _getBonePosition;
  40663. private _getLinesForBonesWithLength;
  40664. private _getLinesForBonesNoLength;
  40665. /** Update the viewer to sync with current skeleton state */
  40666. update(): void;
  40667. /** Release associated resources */
  40668. dispose(): void;
  40669. }
  40670. }
  40671. declare module BABYLON {
  40672. /**
  40673. * Options to create the null engine
  40674. */
  40675. export class NullEngineOptions {
  40676. /**
  40677. * Render width (Default: 512)
  40678. */
  40679. renderWidth: number;
  40680. /**
  40681. * Render height (Default: 256)
  40682. */
  40683. renderHeight: number;
  40684. /**
  40685. * Texture size (Default: 512)
  40686. */
  40687. textureSize: number;
  40688. /**
  40689. * If delta time between frames should be constant
  40690. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40691. */
  40692. deterministicLockstep: boolean;
  40693. /**
  40694. * Maximum about of steps between frames (Default: 4)
  40695. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40696. */
  40697. lockstepMaxSteps: number;
  40698. }
  40699. /**
  40700. * The null engine class provides support for headless version of babylon.js.
  40701. * This can be used in server side scenario or for testing purposes
  40702. */
  40703. export class NullEngine extends Engine {
  40704. private _options;
  40705. /**
  40706. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40707. */
  40708. isDeterministicLockStep(): boolean;
  40709. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40710. getLockstepMaxSteps(): number;
  40711. /**
  40712. * Sets hardware scaling, used to save performance if needed
  40713. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40714. */
  40715. getHardwareScalingLevel(): number;
  40716. constructor(options?: NullEngineOptions);
  40717. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40718. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40719. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40720. getRenderWidth(useScreen?: boolean): number;
  40721. getRenderHeight(useScreen?: boolean): number;
  40722. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40723. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40724. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40725. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40726. bindSamplers(effect: Effect): void;
  40727. enableEffect(effect: Effect): void;
  40728. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40729. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40730. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40731. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40732. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40733. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40734. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40735. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40736. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40737. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40738. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40739. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40740. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40741. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40742. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40743. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40744. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40745. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40746. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40747. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40748. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40749. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40750. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40751. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40752. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40753. bindBuffers(vertexBuffers: {
  40754. [key: string]: VertexBuffer;
  40755. }, indexBuffer: DataBuffer, effect: Effect): void;
  40756. wipeCaches(bruteForce?: boolean): void;
  40757. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40758. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40759. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40760. /** @hidden */ private _createTexture(): WebGLTexture;
  40761. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  40762. 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;
  40763. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40764. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40765. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40766. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40767. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40768. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40769. areAllEffectsReady(): boolean;
  40770. /**
  40771. * @hidden
  40772. * Get the current error code of the webGL context
  40773. * @returns the error code
  40774. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40775. */
  40776. getError(): number;
  40777. /** @hidden */ private _getUnpackAlignement(): number;
  40778. /** @hidden */ private _unpackFlipY(value: boolean): void;
  40779. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40780. /**
  40781. * Updates a dynamic vertex buffer.
  40782. * @param vertexBuffer the vertex buffer to update
  40783. * @param data the data used to update the vertex buffer
  40784. * @param byteOffset the byte offset of the data (optional)
  40785. * @param byteLength the byte length of the data (optional)
  40786. */
  40787. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40788. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  40789. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  40790. releaseEffects(): void;
  40791. displayLoadingUI(): void;
  40792. hideLoadingUI(): void;
  40793. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40794. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40795. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40796. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40797. }
  40798. }
  40799. declare module BABYLON {
  40800. /** @hidden */
  40801. export class _OcclusionDataStorage {
  40802. /** @hidden */
  40803. occlusionInternalRetryCounter: number;
  40804. /** @hidden */
  40805. isOcclusionQueryInProgress: boolean;
  40806. /** @hidden */
  40807. isOccluded: boolean;
  40808. /** @hidden */
  40809. occlusionRetryCount: number;
  40810. /** @hidden */
  40811. occlusionType: number;
  40812. /** @hidden */
  40813. occlusionQueryAlgorithmType: number;
  40814. }
  40815. interface Engine {
  40816. /**
  40817. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40818. * @return the new query
  40819. */
  40820. createQuery(): WebGLQuery;
  40821. /**
  40822. * Delete and release a webGL query
  40823. * @param query defines the query to delete
  40824. * @return the current engine
  40825. */
  40826. deleteQuery(query: WebGLQuery): Engine;
  40827. /**
  40828. * Check if a given query has resolved and got its value
  40829. * @param query defines the query to check
  40830. * @returns true if the query got its value
  40831. */
  40832. isQueryResultAvailable(query: WebGLQuery): boolean;
  40833. /**
  40834. * Gets the value of a given query
  40835. * @param query defines the query to check
  40836. * @returns the value of the query
  40837. */
  40838. getQueryResult(query: WebGLQuery): number;
  40839. /**
  40840. * Initiates an occlusion query
  40841. * @param algorithmType defines the algorithm to use
  40842. * @param query defines the query to use
  40843. * @returns the current engine
  40844. * @see http://doc.babylonjs.com/features/occlusionquery
  40845. */
  40846. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40847. /**
  40848. * Ends an occlusion query
  40849. * @see http://doc.babylonjs.com/features/occlusionquery
  40850. * @param algorithmType defines the algorithm to use
  40851. * @returns the current engine
  40852. */
  40853. endOcclusionQuery(algorithmType: number): Engine;
  40854. /**
  40855. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40856. * Please note that only one query can be issued at a time
  40857. * @returns a time token used to track the time span
  40858. */
  40859. startTimeQuery(): Nullable<_TimeToken>;
  40860. /**
  40861. * Ends a time query
  40862. * @param token defines the token used to measure the time span
  40863. * @returns the time spent (in ns)
  40864. */
  40865. endTimeQuery(token: _TimeToken): int;
  40866. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  40867. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  40868. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  40869. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  40870. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  40871. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  40872. }
  40873. interface AbstractMesh {
  40874. /**
  40875. * Backing filed
  40876. * @hidden
  40877. */ private __occlusionDataStorage: _OcclusionDataStorage;
  40878. /**
  40879. * Access property
  40880. * @hidden
  40881. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40882. /**
  40883. * 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.
  40884. * The default value is -1 which means don't break the query and wait till the result
  40885. * @see http://doc.babylonjs.com/features/occlusionquery
  40886. */
  40887. occlusionRetryCount: number;
  40888. /**
  40889. * 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:
  40890. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40891. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40892. * * 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.
  40893. * @see http://doc.babylonjs.com/features/occlusionquery
  40894. */
  40895. occlusionType: number;
  40896. /**
  40897. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40898. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40899. * * 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.
  40900. * @see http://doc.babylonjs.com/features/occlusionquery
  40901. */
  40902. occlusionQueryAlgorithmType: number;
  40903. /**
  40904. * 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
  40905. * @see http://doc.babylonjs.com/features/occlusionquery
  40906. */
  40907. isOccluded: boolean;
  40908. /**
  40909. * Flag to check the progress status of the query
  40910. * @see http://doc.babylonjs.com/features/occlusionquery
  40911. */
  40912. isOcclusionQueryInProgress: boolean;
  40913. }
  40914. }
  40915. declare module BABYLON {
  40916. /** @hidden */
  40917. export var _forceTransformFeedbackToBundle: boolean;
  40918. interface Engine {
  40919. /**
  40920. * Creates a webGL transform feedback object
  40921. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40922. * @returns the webGL transform feedback object
  40923. */
  40924. createTransformFeedback(): WebGLTransformFeedback;
  40925. /**
  40926. * Delete a webGL transform feedback object
  40927. * @param value defines the webGL transform feedback object to delete
  40928. */
  40929. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40930. /**
  40931. * Bind a webGL transform feedback object to the webgl context
  40932. * @param value defines the webGL transform feedback object to bind
  40933. */
  40934. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40935. /**
  40936. * Begins a transform feedback operation
  40937. * @param usePoints defines if points or triangles must be used
  40938. */
  40939. beginTransformFeedback(usePoints: boolean): void;
  40940. /**
  40941. * Ends a transform feedback operation
  40942. */
  40943. endTransformFeedback(): void;
  40944. /**
  40945. * Specify the varyings to use with transform feedback
  40946. * @param program defines the associated webGL program
  40947. * @param value defines the list of strings representing the varying names
  40948. */
  40949. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40950. /**
  40951. * Bind a webGL buffer for a transform feedback operation
  40952. * @param value defines the webGL buffer to bind
  40953. */
  40954. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  40955. }
  40956. }
  40957. declare module BABYLON {
  40958. /**
  40959. * Creation options of the multi render target texture.
  40960. */
  40961. export interface IMultiRenderTargetOptions {
  40962. /**
  40963. * Define if the texture needs to create mip maps after render.
  40964. */
  40965. generateMipMaps?: boolean;
  40966. /**
  40967. * Define the types of all the draw buffers we want to create
  40968. */
  40969. types?: number[];
  40970. /**
  40971. * Define the sampling modes of all the draw buffers we want to create
  40972. */
  40973. samplingModes?: number[];
  40974. /**
  40975. * Define if a depth buffer is required
  40976. */
  40977. generateDepthBuffer?: boolean;
  40978. /**
  40979. * Define if a stencil buffer is required
  40980. */
  40981. generateStencilBuffer?: boolean;
  40982. /**
  40983. * Define if a depth texture is required instead of a depth buffer
  40984. */
  40985. generateDepthTexture?: boolean;
  40986. /**
  40987. * Define the number of desired draw buffers
  40988. */
  40989. textureCount?: number;
  40990. /**
  40991. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40992. */
  40993. doNotChangeAspectRatio?: boolean;
  40994. /**
  40995. * Define the default type of the buffers we are creating
  40996. */
  40997. defaultType?: number;
  40998. }
  40999. /**
  41000. * A multi render target, like a render target provides the ability to render to a texture.
  41001. * Unlike the render target, it can render to several draw buffers in one draw.
  41002. * This is specially interesting in deferred rendering or for any effects requiring more than
  41003. * just one color from a single pass.
  41004. */
  41005. export class MultiRenderTarget extends RenderTargetTexture {
  41006. private _internalTextures;
  41007. private _textures;
  41008. private _multiRenderTargetOptions;
  41009. /**
  41010. * Get if draw buffers are currently supported by the used hardware and browser.
  41011. */
  41012. readonly isSupported: boolean;
  41013. /**
  41014. * Get the list of textures generated by the multi render target.
  41015. */
  41016. readonly textures: Texture[];
  41017. /**
  41018. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41019. */
  41020. readonly depthTexture: Texture;
  41021. /**
  41022. * Set the wrapping mode on U of all the textures we are rendering to.
  41023. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41024. */
  41025. wrapU: number;
  41026. /**
  41027. * Set the wrapping mode on V of all the textures we are rendering to.
  41028. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41029. */
  41030. wrapV: number;
  41031. /**
  41032. * Instantiate a new multi render target texture.
  41033. * A multi render target, like a render target provides the ability to render to a texture.
  41034. * Unlike the render target, it can render to several draw buffers in one draw.
  41035. * This is specially interesting in deferred rendering or for any effects requiring more than
  41036. * just one color from a single pass.
  41037. * @param name Define the name of the texture
  41038. * @param size Define the size of the buffers to render to
  41039. * @param count Define the number of target we are rendering into
  41040. * @param scene Define the scene the texture belongs to
  41041. * @param options Define the options used to create the multi render target
  41042. */
  41043. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41044. /** @hidden */ private _rebuild(): void;
  41045. private _createInternalTextures;
  41046. private _createTextures;
  41047. /**
  41048. * Define the number of samples used if MSAA is enabled.
  41049. */
  41050. samples: number;
  41051. /**
  41052. * Resize all the textures in the multi render target.
  41053. * Be carrefull as it will recreate all the data in the new texture.
  41054. * @param size Define the new size
  41055. */
  41056. resize(size: any): void;
  41057. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41058. /**
  41059. * Dispose the render targets and their associated resources
  41060. */
  41061. dispose(): void;
  41062. /**
  41063. * Release all the underlying texture used as draw buffers.
  41064. */
  41065. releaseInternalTextures(): void;
  41066. }
  41067. }
  41068. declare module BABYLON {
  41069. interface Engine {
  41070. /**
  41071. * Unbind a list of render target textures from the webGL context
  41072. * This is used only when drawBuffer extension or webGL2 are active
  41073. * @param textures defines the render target textures to unbind
  41074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41076. */
  41077. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41078. /**
  41079. * Create a multi render target texture
  41080. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41081. * @param size defines the size of the texture
  41082. * @param options defines the creation options
  41083. * @returns the cube texture as an InternalTexture
  41084. */
  41085. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41086. /**
  41087. * Update the sample count for a given multiple render target texture
  41088. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41089. * @param textures defines the textures to update
  41090. * @param samples defines the sample count to set
  41091. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41092. */
  41093. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41094. }
  41095. }
  41096. declare module BABYLON {
  41097. /**
  41098. * Gather the list of clipboard event types as constants.
  41099. */
  41100. export class ClipboardEventTypes {
  41101. /**
  41102. * The clipboard event is fired when a copy command is active (pressed).
  41103. */
  41104. static readonly COPY: number;
  41105. /**
  41106. * The clipboard event is fired when a cut command is active (pressed).
  41107. */
  41108. static readonly CUT: number;
  41109. /**
  41110. * The clipboard event is fired when a paste command is active (pressed).
  41111. */
  41112. static readonly PASTE: number;
  41113. }
  41114. /**
  41115. * This class is used to store clipboard related info for the onClipboardObservable event.
  41116. */
  41117. export class ClipboardInfo {
  41118. /**
  41119. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41120. */
  41121. type: number;
  41122. /**
  41123. * Defines the related dom event
  41124. */
  41125. event: ClipboardEvent;
  41126. /**
  41127. *Creates an instance of ClipboardInfo.
  41128. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41129. * @param event Defines the related dom event
  41130. */
  41131. constructor(
  41132. /**
  41133. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41134. */
  41135. type: number,
  41136. /**
  41137. * Defines the related dom event
  41138. */
  41139. event: ClipboardEvent);
  41140. /**
  41141. * Get the clipboard event's type from the keycode.
  41142. * @param keyCode Defines the keyCode for the current keyboard event.
  41143. * @return {number}
  41144. */
  41145. static GetTypeFromCharacter(keyCode: number): number;
  41146. }
  41147. }
  41148. declare module BABYLON {
  41149. /**
  41150. * Class used to represent data loading progression
  41151. */
  41152. export class SceneLoaderProgressEvent {
  41153. /** defines if data length to load can be evaluated */
  41154. readonly lengthComputable: boolean;
  41155. /** defines the loaded data length */
  41156. readonly loaded: number;
  41157. /** defines the data length to load */
  41158. readonly total: number;
  41159. /**
  41160. * Create a new progress event
  41161. * @param lengthComputable defines if data length to load can be evaluated
  41162. * @param loaded defines the loaded data length
  41163. * @param total defines the data length to load
  41164. */
  41165. constructor(
  41166. /** defines if data length to load can be evaluated */
  41167. lengthComputable: boolean,
  41168. /** defines the loaded data length */
  41169. loaded: number,
  41170. /** defines the data length to load */
  41171. total: number);
  41172. /**
  41173. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41174. * @param event defines the source event
  41175. * @returns a new SceneLoaderProgressEvent
  41176. */
  41177. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41178. }
  41179. /**
  41180. * Interface used by SceneLoader plugins to define supported file extensions
  41181. */
  41182. export interface ISceneLoaderPluginExtensions {
  41183. /**
  41184. * Defines the list of supported extensions
  41185. */
  41186. [extension: string]: {
  41187. isBinary: boolean;
  41188. };
  41189. }
  41190. /**
  41191. * Interface used by SceneLoader plugin factory
  41192. */
  41193. export interface ISceneLoaderPluginFactory {
  41194. /**
  41195. * Defines the name of the factory
  41196. */
  41197. name: string;
  41198. /**
  41199. * Function called to create a new plugin
  41200. * @return the new plugin
  41201. */
  41202. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41203. /**
  41204. * Boolean indicating if the plugin can direct load specific data
  41205. */
  41206. canDirectLoad?: (data: string) => boolean;
  41207. }
  41208. /**
  41209. * Interface used to define a SceneLoader plugin
  41210. */
  41211. export interface ISceneLoaderPlugin {
  41212. /**
  41213. * The friendly name of this plugin.
  41214. */
  41215. name: string;
  41216. /**
  41217. * The file extensions supported by this plugin.
  41218. */
  41219. extensions: string | ISceneLoaderPluginExtensions;
  41220. /**
  41221. * Import meshes into a scene.
  41222. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41223. * @param scene The scene to import into
  41224. * @param data The data to import
  41225. * @param rootUrl The root url for scene and resources
  41226. * @param meshes The meshes array to import into
  41227. * @param particleSystems The particle systems array to import into
  41228. * @param skeletons The skeletons array to import into
  41229. * @param onError The callback when import fails
  41230. * @returns True if successful or false otherwise
  41231. */
  41232. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41233. /**
  41234. * Load into a scene.
  41235. * @param scene The scene to load into
  41236. * @param data The data to import
  41237. * @param rootUrl The root url for scene and resources
  41238. * @param onError The callback when import fails
  41239. * @returns true if successful or false otherwise
  41240. */
  41241. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41242. /**
  41243. * The callback that returns true if the data can be directly loaded.
  41244. */
  41245. canDirectLoad?: (data: string) => boolean;
  41246. /**
  41247. * The callback that allows custom handling of the root url based on the response url.
  41248. */
  41249. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41250. /**
  41251. * Load into an asset container.
  41252. * @param scene The scene to load into
  41253. * @param data The data to import
  41254. * @param rootUrl The root url for scene and resources
  41255. * @param onError The callback when import fails
  41256. * @returns The loaded asset container
  41257. */
  41258. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41259. }
  41260. /**
  41261. * Interface used to define an async SceneLoader plugin
  41262. */
  41263. export interface ISceneLoaderPluginAsync {
  41264. /**
  41265. * The friendly name of this plugin.
  41266. */
  41267. name: string;
  41268. /**
  41269. * The file extensions supported by this plugin.
  41270. */
  41271. extensions: string | ISceneLoaderPluginExtensions;
  41272. /**
  41273. * Import meshes into a scene.
  41274. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41275. * @param scene The scene to import into
  41276. * @param data The data to import
  41277. * @param rootUrl The root url for scene and resources
  41278. * @param onProgress The callback when the load progresses
  41279. * @param fileName Defines the name of the file to load
  41280. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41281. */
  41282. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41283. meshes: AbstractMesh[];
  41284. particleSystems: IParticleSystem[];
  41285. skeletons: Skeleton[];
  41286. animationGroups: AnimationGroup[];
  41287. }>;
  41288. /**
  41289. * Load into a scene.
  41290. * @param scene The scene to load into
  41291. * @param data The data to import
  41292. * @param rootUrl The root url for scene and resources
  41293. * @param onProgress The callback when the load progresses
  41294. * @param fileName Defines the name of the file to load
  41295. * @returns Nothing
  41296. */
  41297. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41298. /**
  41299. * The callback that returns true if the data can be directly loaded.
  41300. */
  41301. canDirectLoad?: (data: string) => boolean;
  41302. /**
  41303. * The callback that allows custom handling of the root url based on the response url.
  41304. */
  41305. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41306. /**
  41307. * Load into an asset container.
  41308. * @param scene The scene to load into
  41309. * @param data The data to import
  41310. * @param rootUrl The root url for scene and resources
  41311. * @param onProgress The callback when the load progresses
  41312. * @param fileName Defines the name of the file to load
  41313. * @returns The loaded asset container
  41314. */
  41315. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41316. }
  41317. /**
  41318. * Class used to load scene from various file formats using registered plugins
  41319. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41320. */
  41321. export class SceneLoader {
  41322. /**
  41323. * No logging while loading
  41324. */
  41325. static readonly NO_LOGGING: number;
  41326. /**
  41327. * Minimal logging while loading
  41328. */
  41329. static readonly MINIMAL_LOGGING: number;
  41330. /**
  41331. * Summary logging while loading
  41332. */
  41333. static readonly SUMMARY_LOGGING: number;
  41334. /**
  41335. * Detailled logging while loading
  41336. */
  41337. static readonly DETAILED_LOGGING: number;
  41338. /**
  41339. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41340. */
  41341. static ForceFullSceneLoadingForIncremental: boolean;
  41342. /**
  41343. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41344. */
  41345. static ShowLoadingScreen: boolean;
  41346. /**
  41347. * Defines the current logging level (while loading the scene)
  41348. * @ignorenaming
  41349. */
  41350. static loggingLevel: number;
  41351. /**
  41352. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41353. */
  41354. static CleanBoneMatrixWeights: boolean;
  41355. /**
  41356. * Event raised when a plugin is used to load a scene
  41357. */
  41358. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41359. private static _registeredPlugins;
  41360. private static _getDefaultPlugin;
  41361. private static _getPluginForExtension;
  41362. private static _getPluginForDirectLoad;
  41363. private static _getPluginForFilename;
  41364. private static _getDirectLoad;
  41365. private static _loadData;
  41366. private static _getFileInfo;
  41367. /**
  41368. * Gets a plugin that can load the given extension
  41369. * @param extension defines the extension to load
  41370. * @returns a plugin or null if none works
  41371. */
  41372. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41373. /**
  41374. * Gets a boolean indicating that the given extension can be loaded
  41375. * @param extension defines the extension to load
  41376. * @returns true if the extension is supported
  41377. */
  41378. static IsPluginForExtensionAvailable(extension: string): boolean;
  41379. /**
  41380. * Adds a new plugin to the list of registered plugins
  41381. * @param plugin defines the plugin to add
  41382. */
  41383. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41384. /**
  41385. * Import meshes into a scene
  41386. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41387. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41388. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41389. * @param scene the instance of BABYLON.Scene to append to
  41390. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41391. * @param onProgress a callback with a progress event for each file being loaded
  41392. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41393. * @param pluginExtension the extension used to determine the plugin
  41394. * @returns The loaded plugin
  41395. */
  41396. static 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>;
  41397. /**
  41398. * Import meshes into a scene
  41399. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41400. * @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)
  41401. * @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)
  41402. * @param scene the instance of BABYLON.Scene to append to
  41403. * @param onProgress a callback with a progress event for each file being loaded
  41404. * @param pluginExtension the extension used to determine the plugin
  41405. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41406. */
  41407. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41408. meshes: AbstractMesh[];
  41409. particleSystems: IParticleSystem[];
  41410. skeletons: Skeleton[];
  41411. animationGroups: AnimationGroup[];
  41412. }>;
  41413. /**
  41414. * Load a scene
  41415. * @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)
  41416. * @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)
  41417. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41418. * @param onSuccess a callback with the scene when import succeeds
  41419. * @param onProgress a callback with a progress event for each file being loaded
  41420. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41421. * @param pluginExtension the extension used to determine the plugin
  41422. * @returns The loaded plugin
  41423. */
  41424. 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>;
  41425. /**
  41426. * Load a scene
  41427. * @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)
  41428. * @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)
  41429. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41430. * @param onProgress a callback with a progress event for each file being loaded
  41431. * @param pluginExtension the extension used to determine the plugin
  41432. * @returns The loaded scene
  41433. */
  41434. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41435. /**
  41436. * Append a scene
  41437. * @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)
  41438. * @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)
  41439. * @param scene is the instance of BABYLON.Scene to append to
  41440. * @param onSuccess a callback with the scene when import succeeds
  41441. * @param onProgress a callback with a progress event for each file being loaded
  41442. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41443. * @param pluginExtension the extension used to determine the plugin
  41444. * @returns The loaded plugin
  41445. */
  41446. 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>;
  41447. /**
  41448. * Append a scene
  41449. * @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)
  41450. * @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)
  41451. * @param scene is the instance of BABYLON.Scene to append to
  41452. * @param onProgress a callback with a progress event for each file being loaded
  41453. * @param pluginExtension the extension used to determine the plugin
  41454. * @returns The given scene
  41455. */
  41456. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41457. /**
  41458. * Load a scene into an asset container
  41459. * @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)
  41460. * @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)
  41461. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41462. * @param onSuccess a callback with the scene when import succeeds
  41463. * @param onProgress a callback with a progress event for each file being loaded
  41464. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41465. * @param pluginExtension the extension used to determine the plugin
  41466. * @returns The loaded plugin
  41467. */
  41468. 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>;
  41469. /**
  41470. * Load a scene into an asset container
  41471. * @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)
  41472. * @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)
  41473. * @param scene is the instance of Scene to append to
  41474. * @param onProgress a callback with a progress event for each file being loaded
  41475. * @param pluginExtension the extension used to determine the plugin
  41476. * @returns The loaded asset container
  41477. */
  41478. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41479. }
  41480. }
  41481. declare module BABYLON {
  41482. /**
  41483. * Google Daydream controller
  41484. */
  41485. export class DaydreamController extends WebVRController {
  41486. /**
  41487. * Base Url for the controller model.
  41488. */
  41489. static MODEL_BASE_URL: string;
  41490. /**
  41491. * File name for the controller model.
  41492. */
  41493. static MODEL_FILENAME: string;
  41494. /**
  41495. * Gamepad Id prefix used to identify Daydream Controller.
  41496. */
  41497. static readonly GAMEPAD_ID_PREFIX: string;
  41498. /**
  41499. * Creates a new DaydreamController from a gamepad
  41500. * @param vrGamepad the gamepad that the controller should be created from
  41501. */
  41502. constructor(vrGamepad: any);
  41503. /**
  41504. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41505. * @param scene scene in which to add meshes
  41506. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41507. */
  41508. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41509. /**
  41510. * Called once for each button that changed state since the last frame
  41511. * @param buttonIdx Which button index changed
  41512. * @param state New state of the button
  41513. * @param changes Which properties on the state changed since last frame
  41514. */
  41515. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41516. }
  41517. }
  41518. declare module BABYLON {
  41519. /**
  41520. * Gear VR Controller
  41521. */
  41522. export class GearVRController extends WebVRController {
  41523. /**
  41524. * Base Url for the controller model.
  41525. */
  41526. static MODEL_BASE_URL: string;
  41527. /**
  41528. * File name for the controller model.
  41529. */
  41530. static MODEL_FILENAME: string;
  41531. /**
  41532. * Gamepad Id prefix used to identify this controller.
  41533. */
  41534. static readonly GAMEPAD_ID_PREFIX: string;
  41535. private readonly _buttonIndexToObservableNameMap;
  41536. /**
  41537. * Creates a new GearVRController from a gamepad
  41538. * @param vrGamepad the gamepad that the controller should be created from
  41539. */
  41540. constructor(vrGamepad: any);
  41541. /**
  41542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41543. * @param scene scene in which to add meshes
  41544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41545. */
  41546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41547. /**
  41548. * Called once for each button that changed state since the last frame
  41549. * @param buttonIdx Which button index changed
  41550. * @param state New state of the button
  41551. * @param changes Which properties on the state changed since last frame
  41552. */
  41553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41554. }
  41555. }
  41556. declare module BABYLON {
  41557. /**
  41558. * Generic Controller
  41559. */
  41560. export class GenericController extends WebVRController {
  41561. /**
  41562. * Base Url for the controller model.
  41563. */
  41564. static readonly MODEL_BASE_URL: string;
  41565. /**
  41566. * File name for the controller model.
  41567. */
  41568. static readonly MODEL_FILENAME: string;
  41569. /**
  41570. * Creates a new GenericController from a gamepad
  41571. * @param vrGamepad the gamepad that the controller should be created from
  41572. */
  41573. constructor(vrGamepad: any);
  41574. /**
  41575. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41576. * @param scene scene in which to add meshes
  41577. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41578. */
  41579. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41580. /**
  41581. * Called once for each button that changed state since the last frame
  41582. * @param buttonIdx Which button index changed
  41583. * @param state New state of the button
  41584. * @param changes Which properties on the state changed since last frame
  41585. */
  41586. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41587. }
  41588. }
  41589. declare module BABYLON {
  41590. /**
  41591. * Oculus Touch Controller
  41592. */
  41593. export class OculusTouchController extends WebVRController {
  41594. /**
  41595. * Base Url for the controller model.
  41596. */
  41597. static MODEL_BASE_URL: string;
  41598. /**
  41599. * File name for the left controller model.
  41600. */
  41601. static MODEL_LEFT_FILENAME: string;
  41602. /**
  41603. * File name for the right controller model.
  41604. */
  41605. static MODEL_RIGHT_FILENAME: string;
  41606. /**
  41607. * Fired when the secondary trigger on this controller is modified
  41608. */
  41609. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41610. /**
  41611. * Fired when the thumb rest on this controller is modified
  41612. */
  41613. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41614. /**
  41615. * Creates a new OculusTouchController from a gamepad
  41616. * @param vrGamepad the gamepad that the controller should be created from
  41617. */
  41618. constructor(vrGamepad: any);
  41619. /**
  41620. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41621. * @param scene scene in which to add meshes
  41622. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41623. */
  41624. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41625. /**
  41626. * Fired when the A button on this controller is modified
  41627. */
  41628. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41629. /**
  41630. * Fired when the B button on this controller is modified
  41631. */
  41632. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41633. /**
  41634. * Fired when the X button on this controller is modified
  41635. */
  41636. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41637. /**
  41638. * Fired when the Y button on this controller is modified
  41639. */
  41640. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41641. /**
  41642. * Called once for each button that changed state since the last frame
  41643. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41644. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41645. * 2) secondary trigger (same)
  41646. * 3) A (right) X (left), touch, pressed = value
  41647. * 4) B / Y
  41648. * 5) thumb rest
  41649. * @param buttonIdx Which button index changed
  41650. * @param state New state of the button
  41651. * @param changes Which properties on the state changed since last frame
  41652. */
  41653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41654. }
  41655. }
  41656. declare module BABYLON {
  41657. /**
  41658. * Vive Controller
  41659. */
  41660. export class ViveController extends WebVRController {
  41661. /**
  41662. * Base Url for the controller model.
  41663. */
  41664. static MODEL_BASE_URL: string;
  41665. /**
  41666. * File name for the controller model.
  41667. */
  41668. static MODEL_FILENAME: string;
  41669. /**
  41670. * Creates a new ViveController from a gamepad
  41671. * @param vrGamepad the gamepad that the controller should be created from
  41672. */
  41673. constructor(vrGamepad: any);
  41674. /**
  41675. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41676. * @param scene scene in which to add meshes
  41677. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41678. */
  41679. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41680. /**
  41681. * Fired when the left button on this controller is modified
  41682. */
  41683. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41684. /**
  41685. * Fired when the right button on this controller is modified
  41686. */
  41687. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41688. /**
  41689. * Fired when the menu button on this controller is modified
  41690. */
  41691. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41692. /**
  41693. * Called once for each button that changed state since the last frame
  41694. * Vive mapping:
  41695. * 0: touchpad
  41696. * 1: trigger
  41697. * 2: left AND right buttons
  41698. * 3: menu button
  41699. * @param buttonIdx Which button index changed
  41700. * @param state New state of the button
  41701. * @param changes Which properties on the state changed since last frame
  41702. */
  41703. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41704. }
  41705. }
  41706. declare module BABYLON {
  41707. /**
  41708. * Defines the WindowsMotionController object that the state of the windows motion controller
  41709. */
  41710. export class WindowsMotionController extends WebVRController {
  41711. /**
  41712. * The base url used to load the left and right controller models
  41713. */
  41714. static MODEL_BASE_URL: string;
  41715. /**
  41716. * The name of the left controller model file
  41717. */
  41718. static MODEL_LEFT_FILENAME: string;
  41719. /**
  41720. * The name of the right controller model file
  41721. */
  41722. static MODEL_RIGHT_FILENAME: string;
  41723. /**
  41724. * The controller name prefix for this controller type
  41725. */
  41726. static readonly GAMEPAD_ID_PREFIX: string;
  41727. /**
  41728. * The controller id pattern for this controller type
  41729. */
  41730. private static readonly GAMEPAD_ID_PATTERN;
  41731. private _loadedMeshInfo;
  41732. private readonly _mapping;
  41733. /**
  41734. * Fired when the trackpad on this controller is clicked
  41735. */
  41736. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41737. /**
  41738. * Fired when the trackpad on this controller is modified
  41739. */
  41740. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41741. /**
  41742. * The current x and y values of this controller's trackpad
  41743. */
  41744. trackpad: StickValues;
  41745. /**
  41746. * Creates a new WindowsMotionController from a gamepad
  41747. * @param vrGamepad the gamepad that the controller should be created from
  41748. */
  41749. constructor(vrGamepad: any);
  41750. /**
  41751. * Fired when the trigger on this controller is modified
  41752. */
  41753. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41754. /**
  41755. * Fired when the menu button on this controller is modified
  41756. */
  41757. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41758. /**
  41759. * Fired when the grip button on this controller is modified
  41760. */
  41761. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41762. /**
  41763. * Fired when the thumbstick button on this controller is modified
  41764. */
  41765. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41766. /**
  41767. * Fired when the touchpad button on this controller is modified
  41768. */
  41769. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41770. /**
  41771. * Fired when the touchpad values on this controller are modified
  41772. */
  41773. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41774. private _updateTrackpad;
  41775. /**
  41776. * Called once per frame by the engine.
  41777. */
  41778. update(): void;
  41779. /**
  41780. * Called once for each button that changed state since the last frame
  41781. * @param buttonIdx Which button index changed
  41782. * @param state New state of the button
  41783. * @param changes Which properties on the state changed since last frame
  41784. */
  41785. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41786. /**
  41787. * Moves the buttons on the controller mesh based on their current state
  41788. * @param buttonName the name of the button to move
  41789. * @param buttonValue the value of the button which determines the buttons new position
  41790. */
  41791. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41792. /**
  41793. * Moves the axis on the controller mesh based on its current state
  41794. * @param axis the index of the axis
  41795. * @param axisValue the value of the axis which determines the meshes new position
  41796. * @hidden
  41797. */
  41798. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41799. /**
  41800. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41801. * @param scene scene in which to add meshes
  41802. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41803. */
  41804. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41805. /**
  41806. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41807. * can be transformed by button presses and axes values, based on this._mapping.
  41808. *
  41809. * @param scene scene in which the meshes exist
  41810. * @param meshes list of meshes that make up the controller model to process
  41811. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41812. */
  41813. private processModel;
  41814. private createMeshInfo;
  41815. /**
  41816. * Gets the ray of the controller in the direction the controller is pointing
  41817. * @param length the length the resulting ray should be
  41818. * @returns a ray in the direction the controller is pointing
  41819. */
  41820. getForwardRay(length?: number): Ray;
  41821. /**
  41822. * Disposes of the controller
  41823. */
  41824. dispose(): void;
  41825. }
  41826. }
  41827. declare module BABYLON {
  41828. /**
  41829. * Single axis scale gizmo
  41830. */
  41831. export class AxisScaleGizmo extends Gizmo {
  41832. private _coloredMaterial;
  41833. /**
  41834. * Drag behavior responsible for the gizmos dragging interactions
  41835. */
  41836. dragBehavior: PointerDragBehavior;
  41837. private _pointerObserver;
  41838. /**
  41839. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41840. */
  41841. snapDistance: number;
  41842. /**
  41843. * Event that fires each time the gizmo snaps to a new location.
  41844. * * snapDistance is the the change in distance
  41845. */
  41846. onSnapObservable: Observable<{
  41847. snapDistance: number;
  41848. }>;
  41849. /**
  41850. * If the scaling operation should be done on all axis (default: false)
  41851. */
  41852. uniformScaling: boolean;
  41853. /**
  41854. * Creates an AxisScaleGizmo
  41855. * @param gizmoLayer The utility layer the gizmo will be added to
  41856. * @param dragAxis The axis which the gizmo will be able to scale on
  41857. * @param color The color of the gizmo
  41858. */
  41859. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41860. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41861. /**
  41862. * Disposes of the gizmo
  41863. */
  41864. dispose(): void;
  41865. /**
  41866. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41867. * @param mesh The mesh to replace the default mesh of the gizmo
  41868. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41869. */
  41870. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41871. }
  41872. }
  41873. declare module BABYLON {
  41874. /**
  41875. * Bounding box gizmo
  41876. */
  41877. export class BoundingBoxGizmo extends Gizmo {
  41878. private _lineBoundingBox;
  41879. private _rotateSpheresParent;
  41880. private _scaleBoxesParent;
  41881. private _boundingDimensions;
  41882. private _renderObserver;
  41883. private _pointerObserver;
  41884. private _scaleDragSpeed;
  41885. private _tmpQuaternion;
  41886. private _tmpVector;
  41887. private _tmpRotationMatrix;
  41888. /**
  41889. * 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)
  41890. */
  41891. ignoreChildren: boolean;
  41892. /**
  41893. * 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)
  41894. */
  41895. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41896. /**
  41897. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41898. */
  41899. rotationSphereSize: number;
  41900. /**
  41901. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41902. */
  41903. scaleBoxSize: number;
  41904. /**
  41905. * 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)
  41906. */
  41907. fixedDragMeshScreenSize: boolean;
  41908. /**
  41909. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41910. */
  41911. fixedDragMeshScreenSizeDistanceFactor: number;
  41912. /**
  41913. * Fired when a rotation sphere or scale box is dragged
  41914. */
  41915. onDragStartObservable: Observable<{}>;
  41916. /**
  41917. * Fired when a scale box is dragged
  41918. */
  41919. onScaleBoxDragObservable: Observable<{}>;
  41920. /**
  41921. * Fired when a scale box drag is ended
  41922. */
  41923. onScaleBoxDragEndObservable: Observable<{}>;
  41924. /**
  41925. * Fired when a rotation sphere is dragged
  41926. */
  41927. onRotationSphereDragObservable: Observable<{}>;
  41928. /**
  41929. * Fired when a rotation sphere drag is ended
  41930. */
  41931. onRotationSphereDragEndObservable: Observable<{}>;
  41932. /**
  41933. * 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)
  41934. */
  41935. scalePivot: Nullable<Vector3>;
  41936. /**
  41937. * Mesh used as a pivot to rotate the attached mesh
  41938. */
  41939. private _anchorMesh;
  41940. private _existingMeshScale;
  41941. private _dragMesh;
  41942. private pointerDragBehavior;
  41943. private coloredMaterial;
  41944. private hoverColoredMaterial;
  41945. /**
  41946. * Sets the color of the bounding box gizmo
  41947. * @param color the color to set
  41948. */
  41949. setColor(color: Color3): void;
  41950. /**
  41951. * Creates an BoundingBoxGizmo
  41952. * @param gizmoLayer The utility layer the gizmo will be added to
  41953. * @param color The color of the gizmo
  41954. */
  41955. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41956. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41957. private _selectNode;
  41958. /**
  41959. * Updates the bounding box information for the Gizmo
  41960. */
  41961. updateBoundingBox(): void;
  41962. private _updateRotationSpheres;
  41963. private _updateScaleBoxes;
  41964. /**
  41965. * Enables rotation on the specified axis and disables rotation on the others
  41966. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41967. */
  41968. setEnabledRotationAxis(axis: string): void;
  41969. /**
  41970. * Enables/disables scaling
  41971. * @param enable if scaling should be enabled
  41972. */
  41973. setEnabledScaling(enable: boolean): void;
  41974. private _updateDummy;
  41975. /**
  41976. * Enables a pointer drag behavior on the bounding box of the gizmo
  41977. */
  41978. enableDragBehavior(): void;
  41979. /**
  41980. * Disposes of the gizmo
  41981. */
  41982. dispose(): void;
  41983. /**
  41984. * 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)
  41985. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41986. * @returns the bounding box mesh with the passed in mesh as a child
  41987. */
  41988. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41989. /**
  41990. * CustomMeshes are not supported by this gizmo
  41991. * @param mesh The mesh to replace the default mesh of the gizmo
  41992. */
  41993. setCustomMesh(mesh: Mesh): void;
  41994. }
  41995. }
  41996. declare module BABYLON {
  41997. /**
  41998. * Single plane rotation gizmo
  41999. */
  42000. export class PlaneRotationGizmo extends Gizmo {
  42001. /**
  42002. * Drag behavior responsible for the gizmos dragging interactions
  42003. */
  42004. dragBehavior: PointerDragBehavior;
  42005. private _pointerObserver;
  42006. /**
  42007. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42008. */
  42009. snapDistance: number;
  42010. /**
  42011. * Event that fires each time the gizmo snaps to a new location.
  42012. * * snapDistance is the the change in distance
  42013. */
  42014. onSnapObservable: Observable<{
  42015. snapDistance: number;
  42016. }>;
  42017. /**
  42018. * Creates a PlaneRotationGizmo
  42019. * @param gizmoLayer The utility layer the gizmo will be added to
  42020. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42021. * @param color The color of the gizmo
  42022. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42023. */
  42024. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42025. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42026. /**
  42027. * Disposes of the gizmo
  42028. */
  42029. dispose(): void;
  42030. }
  42031. }
  42032. declare module BABYLON {
  42033. /**
  42034. * Gizmo that enables rotating a mesh along 3 axis
  42035. */
  42036. export class RotationGizmo extends Gizmo {
  42037. /**
  42038. * Internal gizmo used for interactions on the x axis
  42039. */
  42040. xGizmo: PlaneRotationGizmo;
  42041. /**
  42042. * Internal gizmo used for interactions on the y axis
  42043. */
  42044. yGizmo: PlaneRotationGizmo;
  42045. /**
  42046. * Internal gizmo used for interactions on the z axis
  42047. */
  42048. zGizmo: PlaneRotationGizmo;
  42049. /** Fires an event when any of it's sub gizmos are dragged */
  42050. onDragStartObservable: Observable<{}>;
  42051. /** Fires an event when any of it's sub gizmos are released from dragging */
  42052. onDragEndObservable: Observable<{}>;
  42053. attachedMesh: Nullable<AbstractMesh>;
  42054. /**
  42055. * Creates a RotationGizmo
  42056. * @param gizmoLayer The utility layer the gizmo will be added to
  42057. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42058. */
  42059. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42060. updateGizmoRotationToMatchAttachedMesh: boolean;
  42061. /**
  42062. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42063. */
  42064. snapDistance: number;
  42065. /**
  42066. * Ratio for the scale of the gizmo (Default: 1)
  42067. */
  42068. scaleRatio: number;
  42069. /**
  42070. * Disposes of the gizmo
  42071. */
  42072. dispose(): void;
  42073. /**
  42074. * CustomMeshes are not supported by this gizmo
  42075. * @param mesh The mesh to replace the default mesh of the gizmo
  42076. */
  42077. setCustomMesh(mesh: Mesh): void;
  42078. }
  42079. }
  42080. declare module BABYLON {
  42081. /**
  42082. * Gizmo that enables dragging a mesh along 3 axis
  42083. */
  42084. export class PositionGizmo extends Gizmo {
  42085. /**
  42086. * Internal gizmo used for interactions on the x axis
  42087. */
  42088. xGizmo: AxisDragGizmo;
  42089. /**
  42090. * Internal gizmo used for interactions on the y axis
  42091. */
  42092. yGizmo: AxisDragGizmo;
  42093. /**
  42094. * Internal gizmo used for interactions on the z axis
  42095. */
  42096. zGizmo: AxisDragGizmo;
  42097. /** Fires an event when any of it's sub gizmos are dragged */
  42098. onDragStartObservable: Observable<{}>;
  42099. /** Fires an event when any of it's sub gizmos are released from dragging */
  42100. onDragEndObservable: Observable<{}>;
  42101. attachedMesh: Nullable<AbstractMesh>;
  42102. /**
  42103. * Creates a PositionGizmo
  42104. * @param gizmoLayer The utility layer the gizmo will be added to
  42105. */
  42106. constructor(gizmoLayer?: UtilityLayerRenderer);
  42107. updateGizmoRotationToMatchAttachedMesh: boolean;
  42108. /**
  42109. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42110. */
  42111. snapDistance: number;
  42112. /**
  42113. * Ratio for the scale of the gizmo (Default: 1)
  42114. */
  42115. scaleRatio: number;
  42116. /**
  42117. * Disposes of the gizmo
  42118. */
  42119. dispose(): void;
  42120. /**
  42121. * CustomMeshes are not supported by this gizmo
  42122. * @param mesh The mesh to replace the default mesh of the gizmo
  42123. */
  42124. setCustomMesh(mesh: Mesh): void;
  42125. }
  42126. }
  42127. declare module BABYLON {
  42128. /**
  42129. * Class containing static functions to help procedurally build meshes
  42130. */
  42131. export class PolyhedronBuilder {
  42132. /**
  42133. * Creates a polyhedron mesh
  42134. * * 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
  42135. * * The parameter `size` (positive float, default 1) sets the polygon size
  42136. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42137. * * 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`
  42138. * * 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
  42139. * * 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)`)
  42140. * * 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
  42141. * * 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
  42142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42143. * * 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
  42144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42145. * @param name defines the name of the mesh
  42146. * @param options defines the options used to create the mesh
  42147. * @param scene defines the hosting scene
  42148. * @returns the polyhedron mesh
  42149. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42150. */
  42151. static CreatePolyhedron(name: string, options: {
  42152. type?: number;
  42153. size?: number;
  42154. sizeX?: number;
  42155. sizeY?: number;
  42156. sizeZ?: number;
  42157. custom?: any;
  42158. faceUV?: Vector4[];
  42159. faceColors?: Color4[];
  42160. flat?: boolean;
  42161. updatable?: boolean;
  42162. sideOrientation?: number;
  42163. frontUVs?: Vector4;
  42164. backUVs?: Vector4;
  42165. }, scene?: Nullable<Scene>): Mesh;
  42166. }
  42167. }
  42168. declare module BABYLON {
  42169. /**
  42170. * Gizmo that enables scaling a mesh along 3 axis
  42171. */
  42172. export class ScaleGizmo extends Gizmo {
  42173. /**
  42174. * Internal gizmo used for interactions on the x axis
  42175. */
  42176. xGizmo: AxisScaleGizmo;
  42177. /**
  42178. * Internal gizmo used for interactions on the y axis
  42179. */
  42180. yGizmo: AxisScaleGizmo;
  42181. /**
  42182. * Internal gizmo used for interactions on the z axis
  42183. */
  42184. zGizmo: AxisScaleGizmo;
  42185. /**
  42186. * Internal gizmo used to scale all axis equally
  42187. */
  42188. uniformScaleGizmo: AxisScaleGizmo;
  42189. /** Fires an event when any of it's sub gizmos are dragged */
  42190. onDragStartObservable: Observable<{}>;
  42191. /** Fires an event when any of it's sub gizmos are released from dragging */
  42192. onDragEndObservable: Observable<{}>;
  42193. attachedMesh: Nullable<AbstractMesh>;
  42194. /**
  42195. * Creates a ScaleGizmo
  42196. * @param gizmoLayer The utility layer the gizmo will be added to
  42197. */
  42198. constructor(gizmoLayer?: UtilityLayerRenderer);
  42199. updateGizmoRotationToMatchAttachedMesh: boolean;
  42200. /**
  42201. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42202. */
  42203. snapDistance: number;
  42204. /**
  42205. * Ratio for the scale of the gizmo (Default: 1)
  42206. */
  42207. scaleRatio: number;
  42208. /**
  42209. * Disposes of the gizmo
  42210. */
  42211. dispose(): void;
  42212. }
  42213. }
  42214. declare module BABYLON {
  42215. /**
  42216. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42217. */
  42218. export class GizmoManager implements IDisposable {
  42219. private scene;
  42220. /**
  42221. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42222. */
  42223. gizmos: {
  42224. positionGizmo: Nullable<PositionGizmo>;
  42225. rotationGizmo: Nullable<RotationGizmo>;
  42226. scaleGizmo: Nullable<ScaleGizmo>;
  42227. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42228. };
  42229. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42230. clearGizmoOnEmptyPointerEvent: boolean;
  42231. /** Fires an event when the manager is attached to a mesh */
  42232. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42233. private _gizmosEnabled;
  42234. private _pointerObserver;
  42235. private _attachedMesh;
  42236. private _boundingBoxColor;
  42237. private _defaultUtilityLayer;
  42238. private _defaultKeepDepthUtilityLayer;
  42239. /**
  42240. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42241. */
  42242. boundingBoxDragBehavior: SixDofDragBehavior;
  42243. /**
  42244. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42245. */
  42246. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42247. /**
  42248. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42249. */
  42250. usePointerToAttachGizmos: boolean;
  42251. /**
  42252. * Instatiates a gizmo manager
  42253. * @param scene the scene to overlay the gizmos on top of
  42254. */
  42255. constructor(scene: Scene);
  42256. /**
  42257. * Attaches a set of gizmos to the specified mesh
  42258. * @param mesh The mesh the gizmo's should be attached to
  42259. */
  42260. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42261. /**
  42262. * If the position gizmo is enabled
  42263. */
  42264. positionGizmoEnabled: boolean;
  42265. /**
  42266. * If the rotation gizmo is enabled
  42267. */
  42268. rotationGizmoEnabled: boolean;
  42269. /**
  42270. * If the scale gizmo is enabled
  42271. */
  42272. scaleGizmoEnabled: boolean;
  42273. /**
  42274. * If the boundingBox gizmo is enabled
  42275. */
  42276. boundingBoxGizmoEnabled: boolean;
  42277. /**
  42278. * Disposes of the gizmo manager
  42279. */
  42280. dispose(): void;
  42281. }
  42282. }
  42283. declare module BABYLON {
  42284. /**
  42285. * A directional light is defined by a direction (what a surprise!).
  42286. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42287. * 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.
  42288. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42289. */
  42290. export class DirectionalLight extends ShadowLight {
  42291. private _shadowFrustumSize;
  42292. /**
  42293. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42294. */
  42295. /**
  42296. * Specifies a fix frustum size for the shadow generation.
  42297. */
  42298. shadowFrustumSize: number;
  42299. private _shadowOrthoScale;
  42300. /**
  42301. * Gets the shadow projection scale against the optimal computed one.
  42302. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42303. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42304. */
  42305. /**
  42306. * Sets the shadow projection scale against the optimal computed one.
  42307. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42308. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42309. */
  42310. shadowOrthoScale: number;
  42311. /**
  42312. * Automatically compute the projection matrix to best fit (including all the casters)
  42313. * on each frame.
  42314. */
  42315. autoUpdateExtends: boolean;
  42316. private _orthoLeft;
  42317. private _orthoRight;
  42318. private _orthoTop;
  42319. private _orthoBottom;
  42320. /**
  42321. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42322. * The directional light is emitted from everywhere in the given direction.
  42323. * It can cast shadows.
  42324. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42325. * @param name The friendly name of the light
  42326. * @param direction The direction of the light
  42327. * @param scene The scene the light belongs to
  42328. */
  42329. constructor(name: string, direction: Vector3, scene: Scene);
  42330. /**
  42331. * Returns the string "DirectionalLight".
  42332. * @return The class name
  42333. */
  42334. getClassName(): string;
  42335. /**
  42336. * Returns the integer 1.
  42337. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42338. */
  42339. getTypeID(): number;
  42340. /**
  42341. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42342. * Returns the DirectionalLight Shadow projection matrix.
  42343. */
  42344. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42345. /**
  42346. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42347. * Returns the DirectionalLight Shadow projection matrix.
  42348. */
  42349. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42350. /**
  42351. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42352. * Returns the DirectionalLight Shadow projection matrix.
  42353. */
  42354. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42355. protected _buildUniformLayout(): void;
  42356. /**
  42357. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42358. * @param effect The effect to update
  42359. * @param lightIndex The index of the light in the effect to update
  42360. * @returns The directional light
  42361. */
  42362. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42363. /**
  42364. * Gets the minZ used for shadow according to both the scene and the light.
  42365. *
  42366. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42367. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42368. * @param activeCamera The camera we are returning the min for
  42369. * @returns the depth min z
  42370. */
  42371. getDepthMinZ(activeCamera: Camera): number;
  42372. /**
  42373. * Gets the maxZ used for shadow according to both the scene and the light.
  42374. *
  42375. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42376. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42377. * @param activeCamera The camera we are returning the max for
  42378. * @returns the depth max z
  42379. */
  42380. getDepthMaxZ(activeCamera: Camera): number;
  42381. /**
  42382. * Prepares the list of defines specific to the light type.
  42383. * @param defines the list of defines
  42384. * @param lightIndex defines the index of the light for the effect
  42385. */
  42386. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42387. }
  42388. }
  42389. declare module BABYLON {
  42390. /**
  42391. * Class containing static functions to help procedurally build meshes
  42392. */
  42393. export class HemisphereBuilder {
  42394. /**
  42395. * Creates a hemisphere mesh
  42396. * @param name defines the name of the mesh
  42397. * @param options defines the options used to create the mesh
  42398. * @param scene defines the hosting scene
  42399. * @returns the hemisphere mesh
  42400. */
  42401. static CreateHemisphere(name: string, options: {
  42402. segments?: number;
  42403. diameter?: number;
  42404. sideOrientation?: number;
  42405. }, scene: any): Mesh;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42411. * These values define a cone of light starting from the position, emitting toward the direction.
  42412. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42413. * and the exponent defines the speed of the decay of the light with distance (reach).
  42414. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42415. */
  42416. export class SpotLight extends ShadowLight {
  42417. private _angle;
  42418. private _innerAngle;
  42419. private _cosHalfAngle;
  42420. private _lightAngleScale;
  42421. private _lightAngleOffset;
  42422. /**
  42423. * Gets the cone angle of the spot light in Radians.
  42424. */
  42425. /**
  42426. * Sets the cone angle of the spot light in Radians.
  42427. */
  42428. angle: number;
  42429. /**
  42430. * Only used in gltf falloff mode, this defines the angle where
  42431. * the directional falloff will start before cutting at angle which could be seen
  42432. * as outer angle.
  42433. */
  42434. /**
  42435. * Only used in gltf falloff mode, this defines the angle where
  42436. * the directional falloff will start before cutting at angle which could be seen
  42437. * as outer angle.
  42438. */
  42439. innerAngle: number;
  42440. private _shadowAngleScale;
  42441. /**
  42442. * Allows scaling the angle of the light for shadow generation only.
  42443. */
  42444. /**
  42445. * Allows scaling the angle of the light for shadow generation only.
  42446. */
  42447. shadowAngleScale: number;
  42448. /**
  42449. * The light decay speed with the distance from the emission spot.
  42450. */
  42451. exponent: number;
  42452. private _projectionTextureMatrix;
  42453. /**
  42454. * Allows reading the projecton texture
  42455. */
  42456. readonly projectionTextureMatrix: Matrix;
  42457. protected _projectionTextureLightNear: number;
  42458. /**
  42459. * Gets the near clip of the Spotlight for texture projection.
  42460. */
  42461. /**
  42462. * Sets the near clip of the Spotlight for texture projection.
  42463. */
  42464. projectionTextureLightNear: number;
  42465. protected _projectionTextureLightFar: number;
  42466. /**
  42467. * Gets the far clip of the Spotlight for texture projection.
  42468. */
  42469. /**
  42470. * Sets the far clip of the Spotlight for texture projection.
  42471. */
  42472. projectionTextureLightFar: number;
  42473. protected _projectionTextureUpDirection: Vector3;
  42474. /**
  42475. * Gets the Up vector of the Spotlight for texture projection.
  42476. */
  42477. /**
  42478. * Sets the Up vector of the Spotlight for texture projection.
  42479. */
  42480. projectionTextureUpDirection: Vector3;
  42481. private _projectionTexture;
  42482. /**
  42483. * Gets the projection texture of the light.
  42484. */
  42485. /**
  42486. * Sets the projection texture of the light.
  42487. */
  42488. projectionTexture: Nullable<BaseTexture>;
  42489. private _projectionTextureViewLightDirty;
  42490. private _projectionTextureProjectionLightDirty;
  42491. private _projectionTextureDirty;
  42492. private _projectionTextureViewTargetVector;
  42493. private _projectionTextureViewLightMatrix;
  42494. private _projectionTextureProjectionLightMatrix;
  42495. private _projectionTextureScalingMatrix;
  42496. /**
  42497. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42498. * It can cast shadows.
  42499. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42500. * @param name The light friendly name
  42501. * @param position The position of the spot light in the scene
  42502. * @param direction The direction of the light in the scene
  42503. * @param angle The cone angle of the light in Radians
  42504. * @param exponent The light decay speed with the distance from the emission spot
  42505. * @param scene The scene the lights belongs to
  42506. */
  42507. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42508. /**
  42509. * Returns the string "SpotLight".
  42510. * @returns the class name
  42511. */
  42512. getClassName(): string;
  42513. /**
  42514. * Returns the integer 2.
  42515. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42516. */
  42517. getTypeID(): number;
  42518. /**
  42519. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42520. */
  42521. protected _setDirection(value: Vector3): void;
  42522. /**
  42523. * Overrides the position setter to recompute the projection texture view light Matrix.
  42524. */
  42525. protected _setPosition(value: Vector3): void;
  42526. /**
  42527. * 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.
  42528. * Returns the SpotLight.
  42529. */
  42530. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42531. protected _computeProjectionTextureViewLightMatrix(): void;
  42532. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42533. /**
  42534. * Main function for light texture projection matrix computing.
  42535. */
  42536. protected _computeProjectionTextureMatrix(): void;
  42537. protected _buildUniformLayout(): void;
  42538. private _computeAngleValues;
  42539. /**
  42540. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42541. * @param effect The effect to update
  42542. * @param lightIndex The index of the light in the effect to update
  42543. * @returns The spot light
  42544. */
  42545. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42546. /**
  42547. * Disposes the light and the associated resources.
  42548. */
  42549. dispose(): void;
  42550. /**
  42551. * Prepares the list of defines specific to the light type.
  42552. * @param defines the list of defines
  42553. * @param lightIndex defines the index of the light for the effect
  42554. */
  42555. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42556. }
  42557. }
  42558. declare module BABYLON {
  42559. /**
  42560. * Gizmo that enables viewing a light
  42561. */
  42562. export class LightGizmo extends Gizmo {
  42563. private _lightMesh;
  42564. private _material;
  42565. private cachedPosition;
  42566. private cachedForward;
  42567. /**
  42568. * Creates a LightGizmo
  42569. * @param gizmoLayer The utility layer the gizmo will be added to
  42570. */
  42571. constructor(gizmoLayer?: UtilityLayerRenderer);
  42572. private _light;
  42573. /**
  42574. * The light that the gizmo is attached to
  42575. */
  42576. light: Nullable<Light>;
  42577. /**
  42578. * @hidden
  42579. * Updates the gizmo to match the attached mesh's position/rotation
  42580. */
  42581. protected _update(): void;
  42582. private static _Scale;
  42583. /**
  42584. * Creates the lines for a light mesh
  42585. */
  42586. private static _createLightLines;
  42587. /**
  42588. * Disposes of the light gizmo
  42589. */
  42590. dispose(): void;
  42591. private static _CreateHemisphericLightMesh;
  42592. private static _CreatePointLightMesh;
  42593. private static _CreateSpotLightMesh;
  42594. private static _CreateDirectionalLightMesh;
  42595. }
  42596. }
  42597. declare module BABYLON {
  42598. /** @hidden */
  42599. export var backgroundFragmentDeclaration: {
  42600. name: string;
  42601. shader: string;
  42602. };
  42603. }
  42604. declare module BABYLON {
  42605. /** @hidden */
  42606. export var backgroundUboDeclaration: {
  42607. name: string;
  42608. shader: string;
  42609. };
  42610. }
  42611. declare module BABYLON {
  42612. /** @hidden */
  42613. export var backgroundPixelShader: {
  42614. name: string;
  42615. shader: string;
  42616. };
  42617. }
  42618. declare module BABYLON {
  42619. /** @hidden */
  42620. export var backgroundVertexDeclaration: {
  42621. name: string;
  42622. shader: string;
  42623. };
  42624. }
  42625. declare module BABYLON {
  42626. /** @hidden */
  42627. export var backgroundVertexShader: {
  42628. name: string;
  42629. shader: string;
  42630. };
  42631. }
  42632. declare module BABYLON {
  42633. /**
  42634. * Background material used to create an efficient environement around your scene.
  42635. */
  42636. export class BackgroundMaterial extends PushMaterial {
  42637. /**
  42638. * Standard reflectance value at parallel view angle.
  42639. */
  42640. static StandardReflectance0: number;
  42641. /**
  42642. * Standard reflectance value at grazing angle.
  42643. */
  42644. static StandardReflectance90: number;
  42645. protected _primaryColor: Color3;
  42646. /**
  42647. * Key light Color (multiply against the environement texture)
  42648. */
  42649. primaryColor: Color3;
  42650. protected __perceptualColor: Nullable<Color3>;
  42651. /**
  42652. * Experimental Internal Use Only.
  42653. *
  42654. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42655. * This acts as a helper to set the primary color to a more "human friendly" value.
  42656. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42657. * output color as close as possible from the chosen value.
  42658. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42659. * part of lighting setup.)
  42660. */ private _perceptualColor: Nullable<Color3>;
  42661. protected _primaryColorShadowLevel: float;
  42662. /**
  42663. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42664. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42665. */
  42666. primaryColorShadowLevel: float;
  42667. protected _primaryColorHighlightLevel: float;
  42668. /**
  42669. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42670. * The primary color is used at the level chosen to define what the white area would look.
  42671. */
  42672. primaryColorHighlightLevel: float;
  42673. protected _reflectionTexture: Nullable<BaseTexture>;
  42674. /**
  42675. * Reflection Texture used in the material.
  42676. * Should be author in a specific way for the best result (refer to the documentation).
  42677. */
  42678. reflectionTexture: Nullable<BaseTexture>;
  42679. protected _reflectionBlur: float;
  42680. /**
  42681. * Reflection Texture level of blur.
  42682. *
  42683. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42684. * texture twice.
  42685. */
  42686. reflectionBlur: float;
  42687. protected _diffuseTexture: Nullable<BaseTexture>;
  42688. /**
  42689. * Diffuse Texture used in the material.
  42690. * Should be author in a specific way for the best result (refer to the documentation).
  42691. */
  42692. diffuseTexture: Nullable<BaseTexture>;
  42693. protected _shadowLights: Nullable<IShadowLight[]>;
  42694. /**
  42695. * Specify the list of lights casting shadow on the material.
  42696. * All scene shadow lights will be included if null.
  42697. */
  42698. shadowLights: Nullable<IShadowLight[]>;
  42699. protected _shadowLevel: float;
  42700. /**
  42701. * Helps adjusting the shadow to a softer level if required.
  42702. * 0 means black shadows and 1 means no shadows.
  42703. */
  42704. shadowLevel: float;
  42705. protected _sceneCenter: Vector3;
  42706. /**
  42707. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42708. * It is usually zero but might be interesting to modify according to your setup.
  42709. */
  42710. sceneCenter: Vector3;
  42711. protected _opacityFresnel: boolean;
  42712. /**
  42713. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42714. * This helps ensuring a nice transition when the camera goes under the ground.
  42715. */
  42716. opacityFresnel: boolean;
  42717. protected _reflectionFresnel: boolean;
  42718. /**
  42719. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42720. * This helps adding a mirror texture on the ground.
  42721. */
  42722. reflectionFresnel: boolean;
  42723. protected _reflectionFalloffDistance: number;
  42724. /**
  42725. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42726. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42727. */
  42728. reflectionFalloffDistance: number;
  42729. protected _reflectionAmount: number;
  42730. /**
  42731. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42732. */
  42733. reflectionAmount: number;
  42734. protected _reflectionReflectance0: number;
  42735. /**
  42736. * This specifies the weight of the reflection at grazing angle.
  42737. */
  42738. reflectionReflectance0: number;
  42739. protected _reflectionReflectance90: number;
  42740. /**
  42741. * This specifies the weight of the reflection at a perpendicular point of view.
  42742. */
  42743. reflectionReflectance90: number;
  42744. /**
  42745. * Sets the reflection reflectance fresnel values according to the default standard
  42746. * empirically know to work well :-)
  42747. */
  42748. reflectionStandardFresnelWeight: number;
  42749. protected _useRGBColor: boolean;
  42750. /**
  42751. * Helps to directly use the maps channels instead of their level.
  42752. */
  42753. useRGBColor: boolean;
  42754. protected _enableNoise: boolean;
  42755. /**
  42756. * This helps reducing the banding effect that could occur on the background.
  42757. */
  42758. enableNoise: boolean;
  42759. /**
  42760. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42761. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42762. * Recommended to be keep at 1.0 except for special cases.
  42763. */
  42764. fovMultiplier: number;
  42765. private _fovMultiplier;
  42766. /**
  42767. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42768. */
  42769. useEquirectangularFOV: boolean;
  42770. private _maxSimultaneousLights;
  42771. /**
  42772. * Number of Simultaneous lights allowed on the material.
  42773. */
  42774. maxSimultaneousLights: int;
  42775. /**
  42776. * Default configuration related to image processing available in the Background Material.
  42777. */
  42778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42779. /**
  42780. * Keep track of the image processing observer to allow dispose and replace.
  42781. */
  42782. private _imageProcessingObserver;
  42783. /**
  42784. * Attaches a new image processing configuration to the PBR Material.
  42785. * @param configuration (if null the scene configuration will be use)
  42786. */
  42787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42788. /**
  42789. * Gets the image processing configuration used either in this material.
  42790. */
  42791. /**
  42792. * Sets the Default image processing configuration used either in the this material.
  42793. *
  42794. * If sets to null, the scene one is in use.
  42795. */
  42796. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42797. /**
  42798. * Gets wether the color curves effect is enabled.
  42799. */
  42800. /**
  42801. * Sets wether the color curves effect is enabled.
  42802. */
  42803. cameraColorCurvesEnabled: boolean;
  42804. /**
  42805. * Gets wether the color grading effect is enabled.
  42806. */
  42807. /**
  42808. * Gets wether the color grading effect is enabled.
  42809. */
  42810. cameraColorGradingEnabled: boolean;
  42811. /**
  42812. * Gets wether tonemapping is enabled or not.
  42813. */
  42814. /**
  42815. * Sets wether tonemapping is enabled or not
  42816. */
  42817. cameraToneMappingEnabled: boolean;
  42818. /**
  42819. * The camera exposure used on this material.
  42820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42821. * This corresponds to a photographic exposure.
  42822. */
  42823. /**
  42824. * The camera exposure used on this material.
  42825. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42826. * This corresponds to a photographic exposure.
  42827. */
  42828. cameraExposure: float;
  42829. /**
  42830. * Gets The camera contrast used on this material.
  42831. */
  42832. /**
  42833. * Sets The camera contrast used on this material.
  42834. */
  42835. cameraContrast: float;
  42836. /**
  42837. * Gets the Color Grading 2D Lookup Texture.
  42838. */
  42839. /**
  42840. * Sets the Color Grading 2D Lookup Texture.
  42841. */
  42842. cameraColorGradingTexture: Nullable<BaseTexture>;
  42843. /**
  42844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42846. * 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;
  42847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42848. */
  42849. /**
  42850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42852. * 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;
  42853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42854. */
  42855. cameraColorCurves: Nullable<ColorCurves>;
  42856. /**
  42857. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42858. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42859. */
  42860. switchToBGR: boolean;
  42861. private _renderTargets;
  42862. private _reflectionControls;
  42863. private _white;
  42864. private _primaryShadowColor;
  42865. private _primaryHighlightColor;
  42866. /**
  42867. * Instantiates a Background Material in the given scene
  42868. * @param name The friendly name of the material
  42869. * @param scene The scene to add the material to
  42870. */
  42871. constructor(name: string, scene: Scene);
  42872. /**
  42873. * Gets a boolean indicating that current material needs to register RTT
  42874. */
  42875. readonly hasRenderTargetTextures: boolean;
  42876. /**
  42877. * The entire material has been created in order to prevent overdraw.
  42878. * @returns false
  42879. */
  42880. needAlphaTesting(): boolean;
  42881. /**
  42882. * The entire material has been created in order to prevent overdraw.
  42883. * @returns true if blending is enable
  42884. */
  42885. needAlphaBlending(): boolean;
  42886. /**
  42887. * Checks wether the material is ready to be rendered for a given mesh.
  42888. * @param mesh The mesh to render
  42889. * @param subMesh The submesh to check against
  42890. * @param useInstances Specify wether or not the material is used with instances
  42891. * @returns true if all the dependencies are ready (Textures, Effects...)
  42892. */
  42893. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42894. /**
  42895. * Compute the primary color according to the chosen perceptual color.
  42896. */
  42897. private _computePrimaryColorFromPerceptualColor;
  42898. /**
  42899. * Compute the highlights and shadow colors according to their chosen levels.
  42900. */
  42901. private _computePrimaryColors;
  42902. /**
  42903. * Build the uniform buffer used in the material.
  42904. */
  42905. buildUniformLayout(): void;
  42906. /**
  42907. * Unbind the material.
  42908. */
  42909. unbind(): void;
  42910. /**
  42911. * Bind only the world matrix to the material.
  42912. * @param world The world matrix to bind.
  42913. */
  42914. bindOnlyWorldMatrix(world: Matrix): void;
  42915. /**
  42916. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42917. * @param world The world matrix to bind.
  42918. * @param subMesh The submesh to bind for.
  42919. */
  42920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42921. /**
  42922. * Dispose the material.
  42923. * @param forceDisposeEffect Force disposal of the associated effect.
  42924. * @param forceDisposeTextures Force disposal of the associated textures.
  42925. */
  42926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42927. /**
  42928. * Clones the material.
  42929. * @param name The cloned name.
  42930. * @returns The cloned material.
  42931. */
  42932. clone(name: string): BackgroundMaterial;
  42933. /**
  42934. * Serializes the current material to its JSON representation.
  42935. * @returns The JSON representation.
  42936. */
  42937. serialize(): any;
  42938. /**
  42939. * Gets the class name of the material
  42940. * @returns "BackgroundMaterial"
  42941. */
  42942. getClassName(): string;
  42943. /**
  42944. * Parse a JSON input to create back a background material.
  42945. * @param source The JSON data to parse
  42946. * @param scene The scene to create the parsed material in
  42947. * @param rootUrl The root url of the assets the material depends upon
  42948. * @returns the instantiated BackgroundMaterial.
  42949. */
  42950. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42951. }
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Represents the different options available during the creation of
  42956. * a Environment helper.
  42957. *
  42958. * This can control the default ground, skybox and image processing setup of your scene.
  42959. */
  42960. export interface IEnvironmentHelperOptions {
  42961. /**
  42962. * Specifies wether or not to create a ground.
  42963. * True by default.
  42964. */
  42965. createGround: boolean;
  42966. /**
  42967. * Specifies the ground size.
  42968. * 15 by default.
  42969. */
  42970. groundSize: number;
  42971. /**
  42972. * The texture used on the ground for the main color.
  42973. * Comes from the BabylonJS CDN by default.
  42974. *
  42975. * Remarks: Can be either a texture or a url.
  42976. */
  42977. groundTexture: string | BaseTexture;
  42978. /**
  42979. * The color mixed in the ground texture by default.
  42980. * BabylonJS clearColor by default.
  42981. */
  42982. groundColor: Color3;
  42983. /**
  42984. * Specifies the ground opacity.
  42985. * 1 by default.
  42986. */
  42987. groundOpacity: number;
  42988. /**
  42989. * Enables the ground to receive shadows.
  42990. * True by default.
  42991. */
  42992. enableGroundShadow: boolean;
  42993. /**
  42994. * Helps preventing the shadow to be fully black on the ground.
  42995. * 0.5 by default.
  42996. */
  42997. groundShadowLevel: number;
  42998. /**
  42999. * Creates a mirror texture attach to the ground.
  43000. * false by default.
  43001. */
  43002. enableGroundMirror: boolean;
  43003. /**
  43004. * Specifies the ground mirror size ratio.
  43005. * 0.3 by default as the default kernel is 64.
  43006. */
  43007. groundMirrorSizeRatio: number;
  43008. /**
  43009. * Specifies the ground mirror blur kernel size.
  43010. * 64 by default.
  43011. */
  43012. groundMirrorBlurKernel: number;
  43013. /**
  43014. * Specifies the ground mirror visibility amount.
  43015. * 1 by default
  43016. */
  43017. groundMirrorAmount: number;
  43018. /**
  43019. * Specifies the ground mirror reflectance weight.
  43020. * This uses the standard weight of the background material to setup the fresnel effect
  43021. * of the mirror.
  43022. * 1 by default.
  43023. */
  43024. groundMirrorFresnelWeight: number;
  43025. /**
  43026. * Specifies the ground mirror Falloff distance.
  43027. * This can helps reducing the size of the reflection.
  43028. * 0 by Default.
  43029. */
  43030. groundMirrorFallOffDistance: number;
  43031. /**
  43032. * Specifies the ground mirror texture type.
  43033. * Unsigned Int by Default.
  43034. */
  43035. groundMirrorTextureType: number;
  43036. /**
  43037. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43038. * the shown objects.
  43039. */
  43040. groundYBias: number;
  43041. /**
  43042. * Specifies wether or not to create a skybox.
  43043. * True by default.
  43044. */
  43045. createSkybox: boolean;
  43046. /**
  43047. * Specifies the skybox size.
  43048. * 20 by default.
  43049. */
  43050. skyboxSize: number;
  43051. /**
  43052. * The texture used on the skybox for the main color.
  43053. * Comes from the BabylonJS CDN by default.
  43054. *
  43055. * Remarks: Can be either a texture or a url.
  43056. */
  43057. skyboxTexture: string | BaseTexture;
  43058. /**
  43059. * The color mixed in the skybox texture by default.
  43060. * BabylonJS clearColor by default.
  43061. */
  43062. skyboxColor: Color3;
  43063. /**
  43064. * The background rotation around the Y axis of the scene.
  43065. * This helps aligning the key lights of your scene with the background.
  43066. * 0 by default.
  43067. */
  43068. backgroundYRotation: number;
  43069. /**
  43070. * Compute automatically the size of the elements to best fit with the scene.
  43071. */
  43072. sizeAuto: boolean;
  43073. /**
  43074. * Default position of the rootMesh if autoSize is not true.
  43075. */
  43076. rootPosition: Vector3;
  43077. /**
  43078. * Sets up the image processing in the scene.
  43079. * true by default.
  43080. */
  43081. setupImageProcessing: boolean;
  43082. /**
  43083. * The texture used as your environment texture in the scene.
  43084. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43085. *
  43086. * Remarks: Can be either a texture or a url.
  43087. */
  43088. environmentTexture: string | BaseTexture;
  43089. /**
  43090. * The value of the exposure to apply to the scene.
  43091. * 0.6 by default if setupImageProcessing is true.
  43092. */
  43093. cameraExposure: number;
  43094. /**
  43095. * The value of the contrast to apply to the scene.
  43096. * 1.6 by default if setupImageProcessing is true.
  43097. */
  43098. cameraContrast: number;
  43099. /**
  43100. * Specifies wether or not tonemapping should be enabled in the scene.
  43101. * true by default if setupImageProcessing is true.
  43102. */
  43103. toneMappingEnabled: boolean;
  43104. }
  43105. /**
  43106. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43107. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43108. * It also helps with the default setup of your imageProcessing configuration.
  43109. */
  43110. export class EnvironmentHelper {
  43111. /**
  43112. * Default ground texture URL.
  43113. */
  43114. private static _groundTextureCDNUrl;
  43115. /**
  43116. * Default skybox texture URL.
  43117. */
  43118. private static _skyboxTextureCDNUrl;
  43119. /**
  43120. * Default environment texture URL.
  43121. */
  43122. private static _environmentTextureCDNUrl;
  43123. /**
  43124. * Creates the default options for the helper.
  43125. */
  43126. private static _getDefaultOptions;
  43127. private _rootMesh;
  43128. /**
  43129. * Gets the root mesh created by the helper.
  43130. */
  43131. readonly rootMesh: Mesh;
  43132. private _skybox;
  43133. /**
  43134. * Gets the skybox created by the helper.
  43135. */
  43136. readonly skybox: Nullable<Mesh>;
  43137. private _skyboxTexture;
  43138. /**
  43139. * Gets the skybox texture created by the helper.
  43140. */
  43141. readonly skyboxTexture: Nullable<BaseTexture>;
  43142. private _skyboxMaterial;
  43143. /**
  43144. * Gets the skybox material created by the helper.
  43145. */
  43146. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43147. private _ground;
  43148. /**
  43149. * Gets the ground mesh created by the helper.
  43150. */
  43151. readonly ground: Nullable<Mesh>;
  43152. private _groundTexture;
  43153. /**
  43154. * Gets the ground texture created by the helper.
  43155. */
  43156. readonly groundTexture: Nullable<BaseTexture>;
  43157. private _groundMirror;
  43158. /**
  43159. * Gets the ground mirror created by the helper.
  43160. */
  43161. readonly groundMirror: Nullable<MirrorTexture>;
  43162. /**
  43163. * Gets the ground mirror render list to helps pushing the meshes
  43164. * you wish in the ground reflection.
  43165. */
  43166. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43167. private _groundMaterial;
  43168. /**
  43169. * Gets the ground material created by the helper.
  43170. */
  43171. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43172. /**
  43173. * Stores the creation options.
  43174. */
  43175. private readonly _scene;
  43176. private _options;
  43177. /**
  43178. * This observable will be notified with any error during the creation of the environment,
  43179. * mainly texture creation errors.
  43180. */
  43181. onErrorObservable: Observable<{
  43182. message?: string;
  43183. exception?: any;
  43184. }>;
  43185. /**
  43186. * constructor
  43187. * @param options Defines the options we want to customize the helper
  43188. * @param scene The scene to add the material to
  43189. */
  43190. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43191. /**
  43192. * Updates the background according to the new options
  43193. * @param options
  43194. */
  43195. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43196. /**
  43197. * Sets the primary color of all the available elements.
  43198. * @param color the main color to affect to the ground and the background
  43199. */
  43200. setMainColor(color: Color3): void;
  43201. /**
  43202. * Setup the image processing according to the specified options.
  43203. */
  43204. private _setupImageProcessing;
  43205. /**
  43206. * Setup the environment texture according to the specified options.
  43207. */
  43208. private _setupEnvironmentTexture;
  43209. /**
  43210. * Setup the background according to the specified options.
  43211. */
  43212. private _setupBackground;
  43213. /**
  43214. * Get the scene sizes according to the setup.
  43215. */
  43216. private _getSceneSize;
  43217. /**
  43218. * Setup the ground according to the specified options.
  43219. */
  43220. private _setupGround;
  43221. /**
  43222. * Setup the ground material according to the specified options.
  43223. */
  43224. private _setupGroundMaterial;
  43225. /**
  43226. * Setup the ground diffuse texture according to the specified options.
  43227. */
  43228. private _setupGroundDiffuseTexture;
  43229. /**
  43230. * Setup the ground mirror texture according to the specified options.
  43231. */
  43232. private _setupGroundMirrorTexture;
  43233. /**
  43234. * Setup the ground to receive the mirror texture.
  43235. */
  43236. private _setupMirrorInGroundMaterial;
  43237. /**
  43238. * Setup the skybox according to the specified options.
  43239. */
  43240. private _setupSkybox;
  43241. /**
  43242. * Setup the skybox material according to the specified options.
  43243. */
  43244. private _setupSkyboxMaterial;
  43245. /**
  43246. * Setup the skybox reflection texture according to the specified options.
  43247. */
  43248. private _setupSkyboxReflectionTexture;
  43249. private _errorHandler;
  43250. /**
  43251. * Dispose all the elements created by the Helper.
  43252. */
  43253. dispose(): void;
  43254. }
  43255. }
  43256. declare module BABYLON {
  43257. /**
  43258. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43259. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43260. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43261. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43262. */
  43263. export class PhotoDome extends TransformNode {
  43264. private _useDirectMapping;
  43265. /**
  43266. * The texture being displayed on the sphere
  43267. */
  43268. protected _photoTexture: Texture;
  43269. /**
  43270. * Gets or sets the texture being displayed on the sphere
  43271. */
  43272. photoTexture: Texture;
  43273. /**
  43274. * Observable raised when an error occured while loading the 360 image
  43275. */
  43276. onLoadErrorObservable: Observable<string>;
  43277. /**
  43278. * The skybox material
  43279. */
  43280. protected _material: BackgroundMaterial;
  43281. /**
  43282. * The surface used for the skybox
  43283. */
  43284. protected _mesh: Mesh;
  43285. /**
  43286. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43287. * Also see the options.resolution property.
  43288. */
  43289. fovMultiplier: number;
  43290. /**
  43291. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43292. * @param name Element's name, child elements will append suffixes for their own names.
  43293. * @param urlsOfPhoto defines the url of the photo to display
  43294. * @param options defines an object containing optional or exposed sub element properties
  43295. * @param onError defines a callback called when an error occured while loading the texture
  43296. */
  43297. constructor(name: string, urlOfPhoto: string, options: {
  43298. resolution?: number;
  43299. size?: number;
  43300. useDirectMapping?: boolean;
  43301. faceForward?: boolean;
  43302. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43303. /**
  43304. * Releases resources associated with this node.
  43305. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43306. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43307. */
  43308. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43309. }
  43310. }
  43311. declare module BABYLON {
  43312. /** @hidden */
  43313. export var rgbdDecodePixelShader: {
  43314. name: string;
  43315. shader: string;
  43316. };
  43317. }
  43318. declare module BABYLON {
  43319. /**
  43320. * Class used to host texture specific utilities
  43321. */
  43322. export class BRDFTextureTools {
  43323. /**
  43324. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43325. * @param texture the texture to expand.
  43326. */
  43327. private static _ExpandDefaultBRDFTexture;
  43328. /**
  43329. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43330. * @param scene defines the hosting scene
  43331. * @returns the environment BRDF texture
  43332. */
  43333. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43334. private static _environmentBRDFBase64Texture;
  43335. }
  43336. }
  43337. declare module BABYLON {
  43338. /**
  43339. * @hidden
  43340. */
  43341. export interface IMaterialClearCoatDefines {
  43342. CLEARCOAT: boolean;
  43343. CLEARCOAT_DEFAULTIOR: boolean;
  43344. CLEARCOAT_TEXTURE: boolean;
  43345. CLEARCOAT_TEXTUREDIRECTUV: number;
  43346. CLEARCOAT_BUMP: boolean;
  43347. CLEARCOAT_BUMPDIRECTUV: number;
  43348. CLEARCOAT_TINT: boolean;
  43349. CLEARCOAT_TINT_TEXTURE: boolean;
  43350. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43351. /** @hidden */ private _areTexturesDirty: boolean;
  43352. }
  43353. /**
  43354. * Define the code related to the clear coat parameters of the pbr material.
  43355. */
  43356. export class PBRClearCoatConfiguration {
  43357. /**
  43358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43359. * The default fits with a polyurethane material.
  43360. */
  43361. private static readonly _DefaultIndiceOfRefraction;
  43362. private _isEnabled;
  43363. /**
  43364. * Defines if the clear coat is enabled in the material.
  43365. */
  43366. isEnabled: boolean;
  43367. /**
  43368. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43369. */
  43370. intensity: number;
  43371. /**
  43372. * Defines the clear coat layer roughness.
  43373. */
  43374. roughness: number;
  43375. private _indiceOfRefraction;
  43376. /**
  43377. * Defines the indice of refraction of the clear coat.
  43378. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43379. * The default fits with a polyurethane material.
  43380. * Changing the default value is more performance intensive.
  43381. */
  43382. indiceOfRefraction: number;
  43383. private _texture;
  43384. /**
  43385. * Stores the clear coat values in a texture.
  43386. */
  43387. texture: Nullable<BaseTexture>;
  43388. private _bumpTexture;
  43389. /**
  43390. * Define the clear coat specific bump texture.
  43391. */
  43392. bumpTexture: Nullable<BaseTexture>;
  43393. private _isTintEnabled;
  43394. /**
  43395. * Defines if the clear coat tint is enabled in the material.
  43396. */
  43397. isTintEnabled: boolean;
  43398. /**
  43399. * Defines the clear coat tint of the material.
  43400. * This is only use if tint is enabled
  43401. */
  43402. tintColor: Color3;
  43403. /**
  43404. * Defines the distance at which the tint color should be found in the
  43405. * clear coat media.
  43406. * This is only use if tint is enabled
  43407. */
  43408. tintColorAtDistance: number;
  43409. /**
  43410. * Defines the clear coat layer thickness.
  43411. * This is only use if tint is enabled
  43412. */
  43413. tintThickness: number;
  43414. private _tintTexture;
  43415. /**
  43416. * Stores the clear tint values in a texture.
  43417. * rgb is tint
  43418. * a is a thickness factor
  43419. */
  43420. tintTexture: Nullable<BaseTexture>;
  43421. /** @hidden */
  43422. private _internalMarkAllSubMeshesAsTexturesDirty;
  43423. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43424. /**
  43425. * Instantiate a new istance of clear coat configuration.
  43426. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43427. */
  43428. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43429. /**
  43430. * Gets wehter the submesh is ready to be used or not.
  43431. * @param defines the list of "defines" to update.
  43432. * @param scene defines the scene the material belongs to.
  43433. * @param engine defines the engine the material belongs to.
  43434. * @param disableBumpMap defines wether the material disables bump or not.
  43435. * @returns - boolean indicating that the submesh is ready or not.
  43436. */
  43437. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43438. /**
  43439. * Checks to see if a texture is used in the material.
  43440. * @param defines the list of "defines" to update.
  43441. * @param scene defines the scene to the material belongs to.
  43442. */
  43443. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43444. /**
  43445. * Binds the material data.
  43446. * @param uniformBuffer defines the Uniform buffer to fill in.
  43447. * @param scene defines the scene the material belongs to.
  43448. * @param engine defines the engine the material belongs to.
  43449. * @param disableBumpMap defines wether the material disables bump or not.
  43450. * @param isFrozen defines wether the material is frozen or not.
  43451. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43452. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43453. */
  43454. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43455. /**
  43456. * Checks to see if a texture is used in the material.
  43457. * @param texture - Base texture to use.
  43458. * @returns - Boolean specifying if a texture is used in the material.
  43459. */
  43460. hasTexture(texture: BaseTexture): boolean;
  43461. /**
  43462. * Returns an array of the actively used textures.
  43463. * @param activeTextures Array of BaseTextures
  43464. */
  43465. getActiveTextures(activeTextures: BaseTexture[]): void;
  43466. /**
  43467. * Returns the animatable textures.
  43468. * @param animatables Array of animatable textures.
  43469. */
  43470. getAnimatables(animatables: IAnimatable[]): void;
  43471. /**
  43472. * Disposes the resources of the material.
  43473. * @param forceDisposeTextures - Forces the disposal of all textures.
  43474. */
  43475. dispose(forceDisposeTextures?: boolean): void;
  43476. /**
  43477. * Get the current class name of the texture useful for serialization or dynamic coding.
  43478. * @returns "PBRClearCoatConfiguration"
  43479. */
  43480. getClassName(): string;
  43481. /**
  43482. * Add fallbacks to the effect fallbacks list.
  43483. * @param defines defines the Base texture to use.
  43484. * @param fallbacks defines the current fallback list.
  43485. * @param currentRank defines the current fallback rank.
  43486. * @returns the new fallback rank.
  43487. */
  43488. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43489. /**
  43490. * Add the required uniforms to the current list.
  43491. * @param uniforms defines the current uniform list.
  43492. */
  43493. static AddUniforms(uniforms: string[]): void;
  43494. /**
  43495. * Add the required samplers to the current list.
  43496. * @param samplers defines the current sampler list.
  43497. */
  43498. static AddSamplers(samplers: string[]): void;
  43499. /**
  43500. * Add the required uniforms to the current buffer.
  43501. * @param uniformBuffer defines the current uniform buffer.
  43502. */
  43503. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43504. /**
  43505. * Makes a duplicate of the current configuration into another one.
  43506. * @param clearCoatConfiguration define the config where to copy the info
  43507. */
  43508. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43509. /**
  43510. * Serializes this clear coat configuration.
  43511. * @returns - An object with the serialized config.
  43512. */
  43513. serialize(): any;
  43514. /**
  43515. * Parses a Clear Coat Configuration from a serialized object.
  43516. * @param source - Serialized object.
  43517. */
  43518. parse(source: any): void;
  43519. }
  43520. }
  43521. declare module BABYLON {
  43522. /**
  43523. * @hidden
  43524. */
  43525. export interface IMaterialAnisotropicDefines {
  43526. ANISOTROPIC: boolean;
  43527. ANISOTROPIC_TEXTURE: boolean;
  43528. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43529. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  43530. }
  43531. /**
  43532. * Define the code related to the anisotropic parameters of the pbr material.
  43533. */
  43534. export class PBRAnisotropicConfiguration {
  43535. private _isEnabled;
  43536. /**
  43537. * Defines if the anisotropy is enabled in the material.
  43538. */
  43539. isEnabled: boolean;
  43540. /**
  43541. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43542. */
  43543. intensity: number;
  43544. /**
  43545. * Defines if the effect is along the tangents, bitangents or in between.
  43546. * By default, the effect is "strectching" the highlights along the tangents.
  43547. */
  43548. direction: Vector2;
  43549. private _texture;
  43550. /**
  43551. * Stores the anisotropy values in a texture.
  43552. * rg is direction (like normal from -1 to 1)
  43553. * b is a intensity
  43554. */
  43555. texture: Nullable<BaseTexture>;
  43556. /** @hidden */
  43557. private _internalMarkAllSubMeshesAsTexturesDirty;
  43558. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43559. /**
  43560. * Instantiate a new istance of anisotropy configuration.
  43561. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43562. */
  43563. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43564. /**
  43565. * Specifies that the submesh is ready to be used.
  43566. * @param defines the list of "defines" to update.
  43567. * @param scene defines the scene the material belongs to.
  43568. * @returns - boolean indicating that the submesh is ready or not.
  43569. */
  43570. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43571. /**
  43572. * Checks to see if a texture is used in the material.
  43573. * @param defines the list of "defines" to update.
  43574. * @param mesh the mesh we are preparing the defines for.
  43575. * @param scene defines the scene the material belongs to.
  43576. */
  43577. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43578. /**
  43579. * Binds the material data.
  43580. * @param uniformBuffer defines the Uniform buffer to fill in.
  43581. * @param scene defines the scene the material belongs to.
  43582. * @param isFrozen defines wether the material is frozen or not.
  43583. */
  43584. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43585. /**
  43586. * Checks to see if a texture is used in the material.
  43587. * @param texture - Base texture to use.
  43588. * @returns - Boolean specifying if a texture is used in the material.
  43589. */
  43590. hasTexture(texture: BaseTexture): boolean;
  43591. /**
  43592. * Returns an array of the actively used textures.
  43593. * @param activeTextures Array of BaseTextures
  43594. */
  43595. getActiveTextures(activeTextures: BaseTexture[]): void;
  43596. /**
  43597. * Returns the animatable textures.
  43598. * @param animatables Array of animatable textures.
  43599. */
  43600. getAnimatables(animatables: IAnimatable[]): void;
  43601. /**
  43602. * Disposes the resources of the material.
  43603. * @param forceDisposeTextures - Forces the disposal of all textures.
  43604. */
  43605. dispose(forceDisposeTextures?: boolean): void;
  43606. /**
  43607. * Get the current class name of the texture useful for serialization or dynamic coding.
  43608. * @returns "PBRAnisotropicConfiguration"
  43609. */
  43610. getClassName(): string;
  43611. /**
  43612. * Add fallbacks to the effect fallbacks list.
  43613. * @param defines defines the Base texture to use.
  43614. * @param fallbacks defines the current fallback list.
  43615. * @param currentRank defines the current fallback rank.
  43616. * @returns the new fallback rank.
  43617. */
  43618. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43619. /**
  43620. * Add the required uniforms to the current list.
  43621. * @param uniforms defines the current uniform list.
  43622. */
  43623. static AddUniforms(uniforms: string[]): void;
  43624. /**
  43625. * Add the required uniforms to the current buffer.
  43626. * @param uniformBuffer defines the current uniform buffer.
  43627. */
  43628. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43629. /**
  43630. * Add the required samplers to the current list.
  43631. * @param samplers defines the current sampler list.
  43632. */
  43633. static AddSamplers(samplers: string[]): void;
  43634. /**
  43635. * Makes a duplicate of the current configuration into another one.
  43636. * @param anisotropicConfiguration define the config where to copy the info
  43637. */
  43638. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43639. /**
  43640. * Serializes this anisotropy configuration.
  43641. * @returns - An object with the serialized config.
  43642. */
  43643. serialize(): any;
  43644. /**
  43645. * Parses a anisotropy Configuration from a serialized object.
  43646. * @param source - Serialized object.
  43647. */
  43648. parse(source: any): void;
  43649. }
  43650. }
  43651. declare module BABYLON {
  43652. /**
  43653. * @hidden
  43654. */
  43655. export interface IMaterialBRDFDefines {
  43656. BRDF_V_HEIGHT_CORRELATED: boolean;
  43657. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43658. SPHERICAL_HARMONICS: boolean;
  43659. /** @hidden */ private _areMiscDirty: boolean;
  43660. }
  43661. /**
  43662. * Define the code related to the BRDF parameters of the pbr material.
  43663. */
  43664. export class PBRBRDFConfiguration {
  43665. /**
  43666. * Default value used for the energy conservation.
  43667. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43668. */
  43669. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43670. /**
  43671. * Default value used for the Smith Visibility Height Correlated mode.
  43672. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43673. */
  43674. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43675. /**
  43676. * Default value used for the IBL diffuse part.
  43677. * This can help switching back to the polynomials mode globally which is a tiny bit
  43678. * less GPU intensive at the drawback of a lower quality.
  43679. */
  43680. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  43681. private _useEnergyConservation;
  43682. /**
  43683. * Defines if the material uses energy conservation.
  43684. */
  43685. useEnergyConservation: boolean;
  43686. private _useSmithVisibilityHeightCorrelated;
  43687. /**
  43688. * LEGACY Mode set to false
  43689. * Defines if the material uses height smith correlated visibility term.
  43690. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43691. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43692. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43693. * Not relying on height correlated will also disable energy conservation.
  43694. */
  43695. useSmithVisibilityHeightCorrelated: boolean;
  43696. private _useSphericalHarmonics;
  43697. /**
  43698. * LEGACY Mode set to false
  43699. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  43700. * diffuse part of the IBL.
  43701. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  43702. * to the ground truth.
  43703. */
  43704. useSphericalHarmonics: boolean;
  43705. /** @hidden */
  43706. private _internalMarkAllSubMeshesAsMiscDirty;
  43707. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  43708. /**
  43709. * Instantiate a new istance of clear coat configuration.
  43710. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43711. */
  43712. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43713. /**
  43714. * Checks to see if a texture is used in the material.
  43715. * @param defines the list of "defines" to update.
  43716. */
  43717. prepareDefines(defines: IMaterialBRDFDefines): void;
  43718. /**
  43719. * Get the current class name of the texture useful for serialization or dynamic coding.
  43720. * @returns "PBRClearCoatConfiguration"
  43721. */
  43722. getClassName(): string;
  43723. /**
  43724. * Makes a duplicate of the current configuration into another one.
  43725. * @param brdfConfiguration define the config where to copy the info
  43726. */
  43727. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43728. /**
  43729. * Serializes this BRDF configuration.
  43730. * @returns - An object with the serialized config.
  43731. */
  43732. serialize(): any;
  43733. /**
  43734. * Parses a BRDF Configuration from a serialized object.
  43735. * @param source - Serialized object.
  43736. */
  43737. parse(source: any): void;
  43738. }
  43739. }
  43740. declare module BABYLON {
  43741. /**
  43742. * @hidden
  43743. */
  43744. export interface IMaterialSheenDefines {
  43745. SHEEN: boolean;
  43746. SHEEN_TEXTURE: boolean;
  43747. SHEEN_TEXTUREDIRECTUV: number;
  43748. SHEEN_LINKWITHALBEDO: boolean;
  43749. /** @hidden */ private _areTexturesDirty: boolean;
  43750. }
  43751. /**
  43752. * Define the code related to the Sheen parameters of the pbr material.
  43753. */
  43754. export class PBRSheenConfiguration {
  43755. private _isEnabled;
  43756. /**
  43757. * Defines if the material uses sheen.
  43758. */
  43759. isEnabled: boolean;
  43760. private _linkSheenWithAlbedo;
  43761. /**
  43762. * Defines if the sheen is linked to the sheen color.
  43763. */
  43764. linkSheenWithAlbedo: boolean;
  43765. /**
  43766. * Defines the sheen intensity.
  43767. */
  43768. intensity: number;
  43769. /**
  43770. * Defines the sheen color.
  43771. */
  43772. color: Color3;
  43773. private _texture;
  43774. /**
  43775. * Stores the sheen tint values in a texture.
  43776. * rgb is tint
  43777. * a is a intensity
  43778. */
  43779. texture: Nullable<BaseTexture>;
  43780. /** @hidden */
  43781. private _internalMarkAllSubMeshesAsTexturesDirty;
  43782. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43783. /**
  43784. * Instantiate a new istance of clear coat configuration.
  43785. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43786. */
  43787. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43788. /**
  43789. * Specifies that the submesh is ready to be used.
  43790. * @param defines the list of "defines" to update.
  43791. * @param scene defines the scene the material belongs to.
  43792. * @returns - boolean indicating that the submesh is ready or not.
  43793. */
  43794. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43795. /**
  43796. * Checks to see if a texture is used in the material.
  43797. * @param defines the list of "defines" to update.
  43798. * @param scene defines the scene the material belongs to.
  43799. */
  43800. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43801. /**
  43802. * Binds the material data.
  43803. * @param uniformBuffer defines the Uniform buffer to fill in.
  43804. * @param scene defines the scene the material belongs to.
  43805. * @param isFrozen defines wether the material is frozen or not.
  43806. */
  43807. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43808. /**
  43809. * Checks to see if a texture is used in the material.
  43810. * @param texture - Base texture to use.
  43811. * @returns - Boolean specifying if a texture is used in the material.
  43812. */
  43813. hasTexture(texture: BaseTexture): boolean;
  43814. /**
  43815. * Returns an array of the actively used textures.
  43816. * @param activeTextures Array of BaseTextures
  43817. */
  43818. getActiveTextures(activeTextures: BaseTexture[]): void;
  43819. /**
  43820. * Returns the animatable textures.
  43821. * @param animatables Array of animatable textures.
  43822. */
  43823. getAnimatables(animatables: IAnimatable[]): void;
  43824. /**
  43825. * Disposes the resources of the material.
  43826. * @param forceDisposeTextures - Forces the disposal of all textures.
  43827. */
  43828. dispose(forceDisposeTextures?: boolean): void;
  43829. /**
  43830. * Get the current class name of the texture useful for serialization or dynamic coding.
  43831. * @returns "PBRSheenConfiguration"
  43832. */
  43833. getClassName(): string;
  43834. /**
  43835. * Add fallbacks to the effect fallbacks list.
  43836. * @param defines defines the Base texture to use.
  43837. * @param fallbacks defines the current fallback list.
  43838. * @param currentRank defines the current fallback rank.
  43839. * @returns the new fallback rank.
  43840. */
  43841. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43842. /**
  43843. * Add the required uniforms to the current list.
  43844. * @param uniforms defines the current uniform list.
  43845. */
  43846. static AddUniforms(uniforms: string[]): void;
  43847. /**
  43848. * Add the required uniforms to the current buffer.
  43849. * @param uniformBuffer defines the current uniform buffer.
  43850. */
  43851. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43852. /**
  43853. * Add the required samplers to the current list.
  43854. * @param samplers defines the current sampler list.
  43855. */
  43856. static AddSamplers(samplers: string[]): void;
  43857. /**
  43858. * Makes a duplicate of the current configuration into another one.
  43859. * @param sheenConfiguration define the config where to copy the info
  43860. */
  43861. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43862. /**
  43863. * Serializes this BRDF configuration.
  43864. * @returns - An object with the serialized config.
  43865. */
  43866. serialize(): any;
  43867. /**
  43868. * Parses a Sheen Configuration from a serialized object.
  43869. * @param source - Serialized object.
  43870. */
  43871. parse(source: any): void;
  43872. }
  43873. }
  43874. declare module BABYLON {
  43875. /**
  43876. * @hidden
  43877. */
  43878. export interface IMaterialSubSurfaceDefines {
  43879. SUBSURFACE: boolean;
  43880. SS_REFRACTION: boolean;
  43881. SS_TRANSLUCENCY: boolean;
  43882. SS_SCATERRING: boolean;
  43883. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43884. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43885. SS_REFRACTIONMAP_3D: boolean;
  43886. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43887. SS_LODINREFRACTIONALPHA: boolean;
  43888. SS_GAMMAREFRACTION: boolean;
  43889. SS_RGBDREFRACTION: boolean;
  43890. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43891. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43892. /** @hidden */ private _areTexturesDirty: boolean;
  43893. }
  43894. /**
  43895. * Define the code related to the sub surface parameters of the pbr material.
  43896. */
  43897. export class PBRSubSurfaceConfiguration {
  43898. private _isRefractionEnabled;
  43899. /**
  43900. * Defines if the refraction is enabled in the material.
  43901. */
  43902. isRefractionEnabled: boolean;
  43903. private _isTranslucencyEnabled;
  43904. /**
  43905. * Defines if the translucency is enabled in the material.
  43906. */
  43907. isTranslucencyEnabled: boolean;
  43908. private _isScatteringEnabled;
  43909. /**
  43910. * Defines the refraction intensity of the material.
  43911. * The refraction when enabled replaces the Diffuse part of the material.
  43912. * The intensity helps transitionning between diffuse and refraction.
  43913. */
  43914. refractionIntensity: number;
  43915. /**
  43916. * Defines the translucency intensity of the material.
  43917. * When translucency has been enabled, this defines how much of the "translucency"
  43918. * is addded to the diffuse part of the material.
  43919. */
  43920. translucencyIntensity: number;
  43921. /**
  43922. * Defines the scattering intensity of the material.
  43923. * When scattering has been enabled, this defines how much of the "scattered light"
  43924. * is addded to the diffuse part of the material.
  43925. */
  43926. scatteringIntensity: number;
  43927. private _thicknessTexture;
  43928. /**
  43929. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43930. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43931. * 0 would mean minimumThickness
  43932. * 1 would mean maximumThickness
  43933. * The other channels might be use as a mask to vary the different effects intensity.
  43934. */
  43935. thicknessTexture: Nullable<BaseTexture>;
  43936. private _refractionTexture;
  43937. /**
  43938. * Defines the texture to use for refraction.
  43939. */
  43940. refractionTexture: Nullable<BaseTexture>;
  43941. private _indexOfRefraction;
  43942. /**
  43943. * Defines the indice of refraction used in the material.
  43944. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43945. */
  43946. indexOfRefraction: number;
  43947. private _invertRefractionY;
  43948. /**
  43949. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43950. */
  43951. invertRefractionY: boolean;
  43952. private _linkRefractionWithTransparency;
  43953. /**
  43954. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43955. * Materials half opaque for instance using refraction could benefit from this control.
  43956. */
  43957. linkRefractionWithTransparency: boolean;
  43958. /**
  43959. * Defines the minimum thickness stored in the thickness map.
  43960. * If no thickness map is defined, this value will be used to simulate thickness.
  43961. */
  43962. minimumThickness: number;
  43963. /**
  43964. * Defines the maximum thickness stored in the thickness map.
  43965. */
  43966. maximumThickness: number;
  43967. /**
  43968. * Defines the volume tint of the material.
  43969. * This is used for both translucency and scattering.
  43970. */
  43971. tintColor: Color3;
  43972. /**
  43973. * Defines the distance at which the tint color should be found in the media.
  43974. * This is used for refraction only.
  43975. */
  43976. tintColorAtDistance: number;
  43977. /**
  43978. * Defines how far each channel transmit through the media.
  43979. * It is defined as a color to simplify it selection.
  43980. */
  43981. diffusionDistance: Color3;
  43982. private _useMaskFromThicknessTexture;
  43983. /**
  43984. * Stores the intensity of the different subsurface effects in the thickness texture.
  43985. * * the green channel is the translucency intensity.
  43986. * * the blue channel is the scattering intensity.
  43987. * * the alpha channel is the refraction intensity.
  43988. */
  43989. useMaskFromThicknessTexture: boolean;
  43990. /** @hidden */
  43991. private _internalMarkAllSubMeshesAsTexturesDirty;
  43992. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43993. /**
  43994. * Instantiate a new istance of sub surface configuration.
  43995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43996. */
  43997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43998. /**
  43999. * Gets wehter the submesh is ready to be used or not.
  44000. * @param defines the list of "defines" to update.
  44001. * @param scene defines the scene the material belongs to.
  44002. * @returns - boolean indicating that the submesh is ready or not.
  44003. */
  44004. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44005. /**
  44006. * Checks to see if a texture is used in the material.
  44007. * @param defines the list of "defines" to update.
  44008. * @param scene defines the scene to the material belongs to.
  44009. */
  44010. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44011. /**
  44012. * Binds the material data.
  44013. * @param uniformBuffer defines the Uniform buffer to fill in.
  44014. * @param scene defines the scene the material belongs to.
  44015. * @param engine defines the engine the material belongs to.
  44016. * @param isFrozen defines wether the material is frozen or not.
  44017. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44018. */
  44019. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44020. /**
  44021. * Unbinds the material from the mesh.
  44022. * @param activeEffect defines the effect that should be unbound from.
  44023. * @returns true if unbound, otherwise false
  44024. */
  44025. unbind(activeEffect: Effect): boolean;
  44026. /**
  44027. * Returns the texture used for refraction or null if none is used.
  44028. * @param scene defines the scene the material belongs to.
  44029. * @returns - Refraction texture if present. If no refraction texture and refraction
  44030. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44031. */
  44032. private _getRefractionTexture;
  44033. /**
  44034. * Returns true if alpha blending should be disabled.
  44035. */
  44036. readonly disableAlphaBlending: boolean;
  44037. /**
  44038. * Fills the list of render target textures.
  44039. * @param renderTargets the list of render targets to update
  44040. */
  44041. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44042. /**
  44043. * Checks to see if a texture is used in the material.
  44044. * @param texture - Base texture to use.
  44045. * @returns - Boolean specifying if a texture is used in the material.
  44046. */
  44047. hasTexture(texture: BaseTexture): boolean;
  44048. /**
  44049. * Gets a boolean indicating that current material needs to register RTT
  44050. * @returns true if this uses a render target otherwise false.
  44051. */
  44052. hasRenderTargetTextures(): boolean;
  44053. /**
  44054. * Returns an array of the actively used textures.
  44055. * @param activeTextures Array of BaseTextures
  44056. */
  44057. getActiveTextures(activeTextures: BaseTexture[]): void;
  44058. /**
  44059. * Returns the animatable textures.
  44060. * @param animatables Array of animatable textures.
  44061. */
  44062. getAnimatables(animatables: IAnimatable[]): void;
  44063. /**
  44064. * Disposes the resources of the material.
  44065. * @param forceDisposeTextures - Forces the disposal of all textures.
  44066. */
  44067. dispose(forceDisposeTextures?: boolean): void;
  44068. /**
  44069. * Get the current class name of the texture useful for serialization or dynamic coding.
  44070. * @returns "PBRSubSurfaceConfiguration"
  44071. */
  44072. getClassName(): string;
  44073. /**
  44074. * Add fallbacks to the effect fallbacks list.
  44075. * @param defines defines the Base texture to use.
  44076. * @param fallbacks defines the current fallback list.
  44077. * @param currentRank defines the current fallback rank.
  44078. * @returns the new fallback rank.
  44079. */
  44080. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44081. /**
  44082. * Add the required uniforms to the current list.
  44083. * @param uniforms defines the current uniform list.
  44084. */
  44085. static AddUniforms(uniforms: string[]): void;
  44086. /**
  44087. * Add the required samplers to the current list.
  44088. * @param samplers defines the current sampler list.
  44089. */
  44090. static AddSamplers(samplers: string[]): void;
  44091. /**
  44092. * Add the required uniforms to the current buffer.
  44093. * @param uniformBuffer defines the current uniform buffer.
  44094. */
  44095. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44096. /**
  44097. * Makes a duplicate of the current configuration into another one.
  44098. * @param configuration define the config where to copy the info
  44099. */
  44100. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44101. /**
  44102. * Serializes this Sub Surface configuration.
  44103. * @returns - An object with the serialized config.
  44104. */
  44105. serialize(): any;
  44106. /**
  44107. * Parses a Sub Surface Configuration from a serialized object.
  44108. * @param source - Serialized object.
  44109. */
  44110. parse(source: any): void;
  44111. }
  44112. }
  44113. declare module BABYLON {
  44114. /** @hidden */
  44115. export var pbrFragmentDeclaration: {
  44116. name: string;
  44117. shader: string;
  44118. };
  44119. }
  44120. declare module BABYLON {
  44121. /** @hidden */
  44122. export var pbrUboDeclaration: {
  44123. name: string;
  44124. shader: string;
  44125. };
  44126. }
  44127. declare module BABYLON {
  44128. /** @hidden */
  44129. export var pbrFragmentExtraDeclaration: {
  44130. name: string;
  44131. shader: string;
  44132. };
  44133. }
  44134. declare module BABYLON {
  44135. /** @hidden */
  44136. export var pbrFragmentSamplersDeclaration: {
  44137. name: string;
  44138. shader: string;
  44139. };
  44140. }
  44141. declare module BABYLON {
  44142. /** @hidden */
  44143. export var pbrHelperFunctions: {
  44144. name: string;
  44145. shader: string;
  44146. };
  44147. }
  44148. declare module BABYLON {
  44149. /** @hidden */
  44150. export var harmonicsFunctions: {
  44151. name: string;
  44152. shader: string;
  44153. };
  44154. }
  44155. declare module BABYLON {
  44156. /** @hidden */
  44157. export var pbrDirectLightingSetupFunctions: {
  44158. name: string;
  44159. shader: string;
  44160. };
  44161. }
  44162. declare module BABYLON {
  44163. /** @hidden */
  44164. export var pbrDirectLightingFalloffFunctions: {
  44165. name: string;
  44166. shader: string;
  44167. };
  44168. }
  44169. declare module BABYLON {
  44170. /** @hidden */
  44171. export var pbrBRDFFunctions: {
  44172. name: string;
  44173. shader: string;
  44174. };
  44175. }
  44176. declare module BABYLON {
  44177. /** @hidden */
  44178. export var pbrDirectLightingFunctions: {
  44179. name: string;
  44180. shader: string;
  44181. };
  44182. }
  44183. declare module BABYLON {
  44184. /** @hidden */
  44185. export var pbrIBLFunctions: {
  44186. name: string;
  44187. shader: string;
  44188. };
  44189. }
  44190. declare module BABYLON {
  44191. /** @hidden */
  44192. export var pbrDebug: {
  44193. name: string;
  44194. shader: string;
  44195. };
  44196. }
  44197. declare module BABYLON {
  44198. /** @hidden */
  44199. export var pbrPixelShader: {
  44200. name: string;
  44201. shader: string;
  44202. };
  44203. }
  44204. declare module BABYLON {
  44205. /** @hidden */
  44206. export var pbrVertexDeclaration: {
  44207. name: string;
  44208. shader: string;
  44209. };
  44210. }
  44211. declare module BABYLON {
  44212. /** @hidden */
  44213. export var pbrVertexShader: {
  44214. name: string;
  44215. shader: string;
  44216. };
  44217. }
  44218. declare module BABYLON {
  44219. /**
  44220. * Manages the defines for the PBR Material.
  44221. * @hidden
  44222. */
  44223. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44224. PBR: boolean;
  44225. MAINUV1: boolean;
  44226. MAINUV2: boolean;
  44227. UV1: boolean;
  44228. UV2: boolean;
  44229. ALBEDO: boolean;
  44230. ALBEDODIRECTUV: number;
  44231. VERTEXCOLOR: boolean;
  44232. AMBIENT: boolean;
  44233. AMBIENTDIRECTUV: number;
  44234. AMBIENTINGRAYSCALE: boolean;
  44235. OPACITY: boolean;
  44236. VERTEXALPHA: boolean;
  44237. OPACITYDIRECTUV: number;
  44238. OPACITYRGB: boolean;
  44239. ALPHATEST: boolean;
  44240. DEPTHPREPASS: boolean;
  44241. ALPHABLEND: boolean;
  44242. ALPHAFROMALBEDO: boolean;
  44243. ALPHATESTVALUE: string;
  44244. SPECULAROVERALPHA: boolean;
  44245. RADIANCEOVERALPHA: boolean;
  44246. ALPHAFRESNEL: boolean;
  44247. LINEARALPHAFRESNEL: boolean;
  44248. PREMULTIPLYALPHA: boolean;
  44249. EMISSIVE: boolean;
  44250. EMISSIVEDIRECTUV: number;
  44251. REFLECTIVITY: boolean;
  44252. REFLECTIVITYDIRECTUV: number;
  44253. SPECULARTERM: boolean;
  44254. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44255. MICROSURFACEAUTOMATIC: boolean;
  44256. LODBASEDMICROSFURACE: boolean;
  44257. MICROSURFACEMAP: boolean;
  44258. MICROSURFACEMAPDIRECTUV: number;
  44259. METALLICWORKFLOW: boolean;
  44260. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44261. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44262. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44263. AOSTOREINMETALMAPRED: boolean;
  44264. ENVIRONMENTBRDF: boolean;
  44265. ENVIRONMENTBRDF_RGBD: boolean;
  44266. NORMAL: boolean;
  44267. TANGENT: boolean;
  44268. BUMP: boolean;
  44269. BUMPDIRECTUV: number;
  44270. OBJECTSPACE_NORMALMAP: boolean;
  44271. PARALLAX: boolean;
  44272. PARALLAXOCCLUSION: boolean;
  44273. NORMALXYSCALE: boolean;
  44274. LIGHTMAP: boolean;
  44275. LIGHTMAPDIRECTUV: number;
  44276. USELIGHTMAPASSHADOWMAP: boolean;
  44277. GAMMALIGHTMAP: boolean;
  44278. REFLECTION: boolean;
  44279. REFLECTIONMAP_3D: boolean;
  44280. REFLECTIONMAP_SPHERICAL: boolean;
  44281. REFLECTIONMAP_PLANAR: boolean;
  44282. REFLECTIONMAP_CUBIC: boolean;
  44283. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44284. REFLECTIONMAP_PROJECTION: boolean;
  44285. REFLECTIONMAP_SKYBOX: boolean;
  44286. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44287. REFLECTIONMAP_EXPLICIT: boolean;
  44288. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44289. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44290. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44291. INVERTCUBICMAP: boolean;
  44292. USESPHERICALFROMREFLECTIONMAP: boolean;
  44293. SPHERICAL_HARMONICS: boolean;
  44294. USESPHERICALINVERTEX: boolean;
  44295. REFLECTIONMAP_OPPOSITEZ: boolean;
  44296. LODINREFLECTIONALPHA: boolean;
  44297. GAMMAREFLECTION: boolean;
  44298. RGBDREFLECTION: boolean;
  44299. RADIANCEOCCLUSION: boolean;
  44300. HORIZONOCCLUSION: boolean;
  44301. INSTANCES: boolean;
  44302. NUM_BONE_INFLUENCERS: number;
  44303. BonesPerMesh: number;
  44304. BONETEXTURE: boolean;
  44305. NONUNIFORMSCALING: boolean;
  44306. MORPHTARGETS: boolean;
  44307. MORPHTARGETS_NORMAL: boolean;
  44308. MORPHTARGETS_TANGENT: boolean;
  44309. NUM_MORPH_INFLUENCERS: number;
  44310. IMAGEPROCESSING: boolean;
  44311. VIGNETTE: boolean;
  44312. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44313. VIGNETTEBLENDMODEOPAQUE: boolean;
  44314. TONEMAPPING: boolean;
  44315. TONEMAPPING_ACES: boolean;
  44316. CONTRAST: boolean;
  44317. COLORCURVES: boolean;
  44318. COLORGRADING: boolean;
  44319. COLORGRADING3D: boolean;
  44320. SAMPLER3DGREENDEPTH: boolean;
  44321. SAMPLER3DBGRMAP: boolean;
  44322. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44323. EXPOSURE: boolean;
  44324. MULTIVIEW: boolean;
  44325. USEPHYSICALLIGHTFALLOFF: boolean;
  44326. USEGLTFLIGHTFALLOFF: boolean;
  44327. TWOSIDEDLIGHTING: boolean;
  44328. SHADOWFLOAT: boolean;
  44329. CLIPPLANE: boolean;
  44330. CLIPPLANE2: boolean;
  44331. CLIPPLANE3: boolean;
  44332. CLIPPLANE4: boolean;
  44333. POINTSIZE: boolean;
  44334. FOG: boolean;
  44335. LOGARITHMICDEPTH: boolean;
  44336. FORCENORMALFORWARD: boolean;
  44337. SPECULARAA: boolean;
  44338. CLEARCOAT: boolean;
  44339. CLEARCOAT_DEFAULTIOR: boolean;
  44340. CLEARCOAT_TEXTURE: boolean;
  44341. CLEARCOAT_TEXTUREDIRECTUV: number;
  44342. CLEARCOAT_BUMP: boolean;
  44343. CLEARCOAT_BUMPDIRECTUV: number;
  44344. CLEARCOAT_TINT: boolean;
  44345. CLEARCOAT_TINT_TEXTURE: boolean;
  44346. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44347. ANISOTROPIC: boolean;
  44348. ANISOTROPIC_TEXTURE: boolean;
  44349. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44350. BRDF_V_HEIGHT_CORRELATED: boolean;
  44351. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44352. SHEEN: boolean;
  44353. SHEEN_TEXTURE: boolean;
  44354. SHEEN_TEXTUREDIRECTUV: number;
  44355. SHEEN_LINKWITHALBEDO: boolean;
  44356. SUBSURFACE: boolean;
  44357. SS_REFRACTION: boolean;
  44358. SS_TRANSLUCENCY: boolean;
  44359. SS_SCATERRING: boolean;
  44360. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44361. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44362. SS_REFRACTIONMAP_3D: boolean;
  44363. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44364. SS_LODINREFRACTIONALPHA: boolean;
  44365. SS_GAMMAREFRACTION: boolean;
  44366. SS_RGBDREFRACTION: boolean;
  44367. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44368. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44369. UNLIT: boolean;
  44370. DEBUGMODE: number;
  44371. /**
  44372. * Initializes the PBR Material defines.
  44373. */
  44374. constructor();
  44375. /**
  44376. * Resets the PBR Material defines.
  44377. */
  44378. reset(): void;
  44379. }
  44380. /**
  44381. * The Physically based material base class of BJS.
  44382. *
  44383. * This offers the main features of a standard PBR material.
  44384. * For more information, please refer to the documentation :
  44385. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44386. */
  44387. export abstract class PBRBaseMaterial extends PushMaterial {
  44388. /**
  44389. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44390. */
  44391. static readonly PBRMATERIAL_OPAQUE: number;
  44392. /**
  44393. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44394. */
  44395. static readonly PBRMATERIAL_ALPHATEST: number;
  44396. /**
  44397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44398. */
  44399. static readonly PBRMATERIAL_ALPHABLEND: number;
  44400. /**
  44401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44402. * They are also discarded below the alpha cutoff threshold to improve performances.
  44403. */
  44404. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44405. /**
  44406. * Defines the default value of how much AO map is occluding the analytical lights
  44407. * (point spot...).
  44408. */
  44409. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44410. /**
  44411. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44412. */
  44413. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44414. /**
  44415. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44416. * to enhance interoperability with other engines.
  44417. */
  44418. static readonly LIGHTFALLOFF_GLTF: number;
  44419. /**
  44420. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44421. * to enhance interoperability with other materials.
  44422. */
  44423. static readonly LIGHTFALLOFF_STANDARD: number;
  44424. /**
  44425. * Intensity of the direct lights e.g. the four lights available in your scene.
  44426. * This impacts both the direct diffuse and specular highlights.
  44427. */
  44428. protected _directIntensity: number;
  44429. /**
  44430. * Intensity of the emissive part of the material.
  44431. * This helps controlling the emissive effect without modifying the emissive color.
  44432. */
  44433. protected _emissiveIntensity: number;
  44434. /**
  44435. * Intensity of the environment e.g. how much the environment will light the object
  44436. * either through harmonics for rough material or through the refelction for shiny ones.
  44437. */
  44438. protected _environmentIntensity: number;
  44439. /**
  44440. * This is a special control allowing the reduction of the specular highlights coming from the
  44441. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44442. */
  44443. protected _specularIntensity: number;
  44444. /**
  44445. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44446. */
  44447. private _lightingInfos;
  44448. /**
  44449. * Debug Control allowing disabling the bump map on this material.
  44450. */
  44451. protected _disableBumpMap: boolean;
  44452. /**
  44453. * AKA Diffuse Texture in standard nomenclature.
  44454. */
  44455. protected _albedoTexture: Nullable<BaseTexture>;
  44456. /**
  44457. * AKA Occlusion Texture in other nomenclature.
  44458. */
  44459. protected _ambientTexture: Nullable<BaseTexture>;
  44460. /**
  44461. * AKA Occlusion Texture Intensity in other nomenclature.
  44462. */
  44463. protected _ambientTextureStrength: number;
  44464. /**
  44465. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44466. * 1 means it completely occludes it
  44467. * 0 mean it has no impact
  44468. */
  44469. protected _ambientTextureImpactOnAnalyticalLights: number;
  44470. /**
  44471. * Stores the alpha values in a texture.
  44472. */
  44473. protected _opacityTexture: Nullable<BaseTexture>;
  44474. /**
  44475. * Stores the reflection values in a texture.
  44476. */
  44477. protected _reflectionTexture: Nullable<BaseTexture>;
  44478. /**
  44479. * Stores the emissive values in a texture.
  44480. */
  44481. protected _emissiveTexture: Nullable<BaseTexture>;
  44482. /**
  44483. * AKA Specular texture in other nomenclature.
  44484. */
  44485. protected _reflectivityTexture: Nullable<BaseTexture>;
  44486. /**
  44487. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44488. */
  44489. protected _metallicTexture: Nullable<BaseTexture>;
  44490. /**
  44491. * Specifies the metallic scalar of the metallic/roughness workflow.
  44492. * Can also be used to scale the metalness values of the metallic texture.
  44493. */
  44494. protected _metallic: Nullable<number>;
  44495. /**
  44496. * Specifies the roughness scalar of the metallic/roughness workflow.
  44497. * Can also be used to scale the roughness values of the metallic texture.
  44498. */
  44499. protected _roughness: Nullable<number>;
  44500. /**
  44501. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44502. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44503. */
  44504. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44505. /**
  44506. * Stores surface normal data used to displace a mesh in a texture.
  44507. */
  44508. protected _bumpTexture: Nullable<BaseTexture>;
  44509. /**
  44510. * Stores the pre-calculated light information of a mesh in a texture.
  44511. */
  44512. protected _lightmapTexture: Nullable<BaseTexture>;
  44513. /**
  44514. * The color of a material in ambient lighting.
  44515. */
  44516. protected _ambientColor: Color3;
  44517. /**
  44518. * AKA Diffuse Color in other nomenclature.
  44519. */
  44520. protected _albedoColor: Color3;
  44521. /**
  44522. * AKA Specular Color in other nomenclature.
  44523. */
  44524. protected _reflectivityColor: Color3;
  44525. /**
  44526. * The color applied when light is reflected from a material.
  44527. */
  44528. protected _reflectionColor: Color3;
  44529. /**
  44530. * The color applied when light is emitted from a material.
  44531. */
  44532. protected _emissiveColor: Color3;
  44533. /**
  44534. * AKA Glossiness in other nomenclature.
  44535. */
  44536. protected _microSurface: number;
  44537. /**
  44538. * Specifies that the material will use the light map as a show map.
  44539. */
  44540. protected _useLightmapAsShadowmap: boolean;
  44541. /**
  44542. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44543. * makes the reflect vector face the model (under horizon).
  44544. */
  44545. protected _useHorizonOcclusion: boolean;
  44546. /**
  44547. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44548. * too much the area relying on ambient texture to define their ambient occlusion.
  44549. */
  44550. protected _useRadianceOcclusion: boolean;
  44551. /**
  44552. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44553. */
  44554. protected _useAlphaFromAlbedoTexture: boolean;
  44555. /**
  44556. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44557. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44558. */
  44559. protected _useSpecularOverAlpha: boolean;
  44560. /**
  44561. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44562. */
  44563. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44564. /**
  44565. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44566. */
  44567. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44568. /**
  44569. * Specifies if the metallic texture contains the roughness information in its green channel.
  44570. */
  44571. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44572. /**
  44573. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44574. */
  44575. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44576. /**
  44577. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44578. */
  44579. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44580. /**
  44581. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44582. */
  44583. protected _useAmbientInGrayScale: boolean;
  44584. /**
  44585. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44586. * The material will try to infer what glossiness each pixel should be.
  44587. */
  44588. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44589. /**
  44590. * Defines the falloff type used in this material.
  44591. * It by default is Physical.
  44592. */
  44593. protected _lightFalloff: number;
  44594. /**
  44595. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44596. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44597. */
  44598. protected _useRadianceOverAlpha: boolean;
  44599. /**
  44600. * Allows using an object space normal map (instead of tangent space).
  44601. */
  44602. protected _useObjectSpaceNormalMap: boolean;
  44603. /**
  44604. * Allows using the bump map in parallax mode.
  44605. */
  44606. protected _useParallax: boolean;
  44607. /**
  44608. * Allows using the bump map in parallax occlusion mode.
  44609. */
  44610. protected _useParallaxOcclusion: boolean;
  44611. /**
  44612. * Controls the scale bias of the parallax mode.
  44613. */
  44614. protected _parallaxScaleBias: number;
  44615. /**
  44616. * If sets to true, disables all the lights affecting the material.
  44617. */
  44618. protected _disableLighting: boolean;
  44619. /**
  44620. * Number of Simultaneous lights allowed on the material.
  44621. */
  44622. protected _maxSimultaneousLights: number;
  44623. /**
  44624. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44625. */
  44626. protected _invertNormalMapX: boolean;
  44627. /**
  44628. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44629. */
  44630. protected _invertNormalMapY: boolean;
  44631. /**
  44632. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44633. */
  44634. protected _twoSidedLighting: boolean;
  44635. /**
  44636. * Defines the alpha limits in alpha test mode.
  44637. */
  44638. protected _alphaCutOff: number;
  44639. /**
  44640. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44641. */
  44642. protected _forceAlphaTest: boolean;
  44643. /**
  44644. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44645. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44646. */
  44647. protected _useAlphaFresnel: boolean;
  44648. /**
  44649. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44650. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44651. */
  44652. protected _useLinearAlphaFresnel: boolean;
  44653. /**
  44654. * The transparency mode of the material.
  44655. */
  44656. protected _transparencyMode: Nullable<number>;
  44657. /**
  44658. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44659. * from cos thetav and roughness:
  44660. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44661. */
  44662. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44663. /**
  44664. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44665. */
  44666. protected _forceIrradianceInFragment: boolean;
  44667. /**
  44668. * Force normal to face away from face.
  44669. */
  44670. protected _forceNormalForward: boolean;
  44671. /**
  44672. * Enables specular anti aliasing in the PBR shader.
  44673. * It will both interacts on the Geometry for analytical and IBL lighting.
  44674. * It also prefilter the roughness map based on the bump values.
  44675. */
  44676. protected _enableSpecularAntiAliasing: boolean;
  44677. /**
  44678. * Default configuration related to image processing available in the PBR Material.
  44679. */
  44680. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44681. /**
  44682. * Keep track of the image processing observer to allow dispose and replace.
  44683. */
  44684. private _imageProcessingObserver;
  44685. /**
  44686. * Attaches a new image processing configuration to the PBR Material.
  44687. * @param configuration
  44688. */
  44689. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44690. /**
  44691. * Stores the available render targets.
  44692. */
  44693. private _renderTargets;
  44694. /**
  44695. * Sets the global ambient color for the material used in lighting calculations.
  44696. */
  44697. private _globalAmbientColor;
  44698. /**
  44699. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44700. */
  44701. private _useLogarithmicDepth;
  44702. /**
  44703. * If set to true, no lighting calculations will be applied.
  44704. */
  44705. private _unlit;
  44706. private _debugMode;
  44707. /**
  44708. * @hidden
  44709. * This is reserved for the inspector.
  44710. * Defines the material debug mode.
  44711. * It helps seeing only some components of the material while troubleshooting.
  44712. */
  44713. debugMode: number;
  44714. /**
  44715. * @hidden
  44716. * This is reserved for the inspector.
  44717. * Specify from where on screen the debug mode should start.
  44718. * The value goes from -1 (full screen) to 1 (not visible)
  44719. * It helps with side by side comparison against the final render
  44720. * This defaults to -1
  44721. */
  44722. private debugLimit;
  44723. /**
  44724. * @hidden
  44725. * This is reserved for the inspector.
  44726. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44727. * You can use the factor to better multiply the final value.
  44728. */
  44729. private debugFactor;
  44730. /**
  44731. * Defines the clear coat layer parameters for the material.
  44732. */
  44733. readonly clearCoat: PBRClearCoatConfiguration;
  44734. /**
  44735. * Defines the anisotropic parameters for the material.
  44736. */
  44737. readonly anisotropy: PBRAnisotropicConfiguration;
  44738. /**
  44739. * Defines the BRDF parameters for the material.
  44740. */
  44741. readonly brdf: PBRBRDFConfiguration;
  44742. /**
  44743. * Defines the Sheen parameters for the material.
  44744. */
  44745. readonly sheen: PBRSheenConfiguration;
  44746. /**
  44747. * Defines the SubSurface parameters for the material.
  44748. */
  44749. readonly subSurface: PBRSubSurfaceConfiguration;
  44750. /**
  44751. * Custom callback helping to override the default shader used in the material.
  44752. */
  44753. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44754. /**
  44755. * Instantiates a new PBRMaterial instance.
  44756. *
  44757. * @param name The material name
  44758. * @param scene The scene the material will be use in.
  44759. */
  44760. constructor(name: string, scene: Scene);
  44761. /**
  44762. * Gets a boolean indicating that current material needs to register RTT
  44763. */
  44764. readonly hasRenderTargetTextures: boolean;
  44765. /**
  44766. * Gets the name of the material class.
  44767. */
  44768. getClassName(): string;
  44769. /**
  44770. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44771. */
  44772. /**
  44773. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44774. */
  44775. useLogarithmicDepth: boolean;
  44776. /**
  44777. * Gets the current transparency mode.
  44778. */
  44779. /**
  44780. * Sets the transparency mode of the material.
  44781. *
  44782. * | Value | Type | Description |
  44783. * | ----- | ----------------------------------- | ----------- |
  44784. * | 0 | OPAQUE | |
  44785. * | 1 | ALPHATEST | |
  44786. * | 2 | ALPHABLEND | |
  44787. * | 3 | ALPHATESTANDBLEND | |
  44788. *
  44789. */
  44790. transparencyMode: Nullable<number>;
  44791. /**
  44792. * Returns true if alpha blending should be disabled.
  44793. */
  44794. private readonly _disableAlphaBlending;
  44795. /**
  44796. * Specifies whether or not this material should be rendered in alpha blend mode.
  44797. */
  44798. needAlphaBlending(): boolean;
  44799. /**
  44800. * Specifies if the mesh will require alpha blending.
  44801. * @param mesh - BJS mesh.
  44802. */
  44803. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44804. /**
  44805. * Specifies whether or not this material should be rendered in alpha test mode.
  44806. */
  44807. needAlphaTesting(): boolean;
  44808. /**
  44809. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44810. */
  44811. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44812. /**
  44813. * Gets the texture used for the alpha test.
  44814. */
  44815. getAlphaTestTexture(): Nullable<BaseTexture>;
  44816. /**
  44817. * Specifies that the submesh is ready to be used.
  44818. * @param mesh - BJS mesh.
  44819. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44820. * @param useInstances - Specifies that instances should be used.
  44821. * @returns - boolean indicating that the submesh is ready or not.
  44822. */
  44823. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44824. /**
  44825. * Specifies if the material uses metallic roughness workflow.
  44826. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44827. */
  44828. isMetallicWorkflow(): boolean;
  44829. private _prepareEffect;
  44830. private _prepareDefines;
  44831. /**
  44832. * Force shader compilation
  44833. */
  44834. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44835. clipPlane: boolean;
  44836. }>): void;
  44837. /**
  44838. * Initializes the uniform buffer layout for the shader.
  44839. */
  44840. buildUniformLayout(): void;
  44841. /**
  44842. * Unbinds the material from the mesh
  44843. */
  44844. unbind(): void;
  44845. /**
  44846. * Binds the submesh data.
  44847. * @param world - The world matrix.
  44848. * @param mesh - The BJS mesh.
  44849. * @param subMesh - A submesh of the BJS mesh.
  44850. */
  44851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44852. /**
  44853. * Returns the animatable textures.
  44854. * @returns - Array of animatable textures.
  44855. */
  44856. getAnimatables(): IAnimatable[];
  44857. /**
  44858. * Returns the texture used for reflections.
  44859. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44860. */
  44861. private _getReflectionTexture;
  44862. /**
  44863. * Returns an array of the actively used textures.
  44864. * @returns - Array of BaseTextures
  44865. */
  44866. getActiveTextures(): BaseTexture[];
  44867. /**
  44868. * Checks to see if a texture is used in the material.
  44869. * @param texture - Base texture to use.
  44870. * @returns - Boolean specifying if a texture is used in the material.
  44871. */
  44872. hasTexture(texture: BaseTexture): boolean;
  44873. /**
  44874. * Disposes the resources of the material.
  44875. * @param forceDisposeEffect - Forces the disposal of effects.
  44876. * @param forceDisposeTextures - Forces the disposal of all textures.
  44877. */
  44878. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44879. }
  44880. }
  44881. declare module BABYLON {
  44882. /**
  44883. * The Physically based material of BJS.
  44884. *
  44885. * This offers the main features of a standard PBR material.
  44886. * For more information, please refer to the documentation :
  44887. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44888. */
  44889. export class PBRMaterial extends PBRBaseMaterial {
  44890. /**
  44891. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44892. */
  44893. static readonly PBRMATERIAL_OPAQUE: number;
  44894. /**
  44895. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44896. */
  44897. static readonly PBRMATERIAL_ALPHATEST: number;
  44898. /**
  44899. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44900. */
  44901. static readonly PBRMATERIAL_ALPHABLEND: number;
  44902. /**
  44903. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44904. * They are also discarded below the alpha cutoff threshold to improve performances.
  44905. */
  44906. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44907. /**
  44908. * Defines the default value of how much AO map is occluding the analytical lights
  44909. * (point spot...).
  44910. */
  44911. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44912. /**
  44913. * Intensity of the direct lights e.g. the four lights available in your scene.
  44914. * This impacts both the direct diffuse and specular highlights.
  44915. */
  44916. directIntensity: number;
  44917. /**
  44918. * Intensity of the emissive part of the material.
  44919. * This helps controlling the emissive effect without modifying the emissive color.
  44920. */
  44921. emissiveIntensity: number;
  44922. /**
  44923. * Intensity of the environment e.g. how much the environment will light the object
  44924. * either through harmonics for rough material or through the refelction for shiny ones.
  44925. */
  44926. environmentIntensity: number;
  44927. /**
  44928. * This is a special control allowing the reduction of the specular highlights coming from the
  44929. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44930. */
  44931. specularIntensity: number;
  44932. /**
  44933. * Debug Control allowing disabling the bump map on this material.
  44934. */
  44935. disableBumpMap: boolean;
  44936. /**
  44937. * AKA Diffuse Texture in standard nomenclature.
  44938. */
  44939. albedoTexture: BaseTexture;
  44940. /**
  44941. * AKA Occlusion Texture in other nomenclature.
  44942. */
  44943. ambientTexture: BaseTexture;
  44944. /**
  44945. * AKA Occlusion Texture Intensity in other nomenclature.
  44946. */
  44947. ambientTextureStrength: number;
  44948. /**
  44949. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44950. * 1 means it completely occludes it
  44951. * 0 mean it has no impact
  44952. */
  44953. ambientTextureImpactOnAnalyticalLights: number;
  44954. /**
  44955. * Stores the alpha values in a texture.
  44956. */
  44957. opacityTexture: BaseTexture;
  44958. /**
  44959. * Stores the reflection values in a texture.
  44960. */
  44961. reflectionTexture: Nullable<BaseTexture>;
  44962. /**
  44963. * Stores the emissive values in a texture.
  44964. */
  44965. emissiveTexture: BaseTexture;
  44966. /**
  44967. * AKA Specular texture in other nomenclature.
  44968. */
  44969. reflectivityTexture: BaseTexture;
  44970. /**
  44971. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44972. */
  44973. metallicTexture: BaseTexture;
  44974. /**
  44975. * Specifies the metallic scalar of the metallic/roughness workflow.
  44976. * Can also be used to scale the metalness values of the metallic texture.
  44977. */
  44978. metallic: Nullable<number>;
  44979. /**
  44980. * Specifies the roughness scalar of the metallic/roughness workflow.
  44981. * Can also be used to scale the roughness values of the metallic texture.
  44982. */
  44983. roughness: Nullable<number>;
  44984. /**
  44985. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44986. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44987. */
  44988. microSurfaceTexture: BaseTexture;
  44989. /**
  44990. * Stores surface normal data used to displace a mesh in a texture.
  44991. */
  44992. bumpTexture: BaseTexture;
  44993. /**
  44994. * Stores the pre-calculated light information of a mesh in a texture.
  44995. */
  44996. lightmapTexture: BaseTexture;
  44997. /**
  44998. * Stores the refracted light information in a texture.
  44999. */
  45000. refractionTexture: Nullable<BaseTexture>;
  45001. /**
  45002. * The color of a material in ambient lighting.
  45003. */
  45004. ambientColor: Color3;
  45005. /**
  45006. * AKA Diffuse Color in other nomenclature.
  45007. */
  45008. albedoColor: Color3;
  45009. /**
  45010. * AKA Specular Color in other nomenclature.
  45011. */
  45012. reflectivityColor: Color3;
  45013. /**
  45014. * The color reflected from the material.
  45015. */
  45016. reflectionColor: Color3;
  45017. /**
  45018. * The color emitted from the material.
  45019. */
  45020. emissiveColor: Color3;
  45021. /**
  45022. * AKA Glossiness in other nomenclature.
  45023. */
  45024. microSurface: number;
  45025. /**
  45026. * source material index of refraction (IOR)' / 'destination material IOR.
  45027. */
  45028. indexOfRefraction: number;
  45029. /**
  45030. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45031. */
  45032. invertRefractionY: boolean;
  45033. /**
  45034. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45035. * Materials half opaque for instance using refraction could benefit from this control.
  45036. */
  45037. linkRefractionWithTransparency: boolean;
  45038. /**
  45039. * If true, the light map contains occlusion information instead of lighting info.
  45040. */
  45041. useLightmapAsShadowmap: boolean;
  45042. /**
  45043. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45044. */
  45045. useAlphaFromAlbedoTexture: boolean;
  45046. /**
  45047. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45048. */
  45049. forceAlphaTest: boolean;
  45050. /**
  45051. * Defines the alpha limits in alpha test mode.
  45052. */
  45053. alphaCutOff: number;
  45054. /**
  45055. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45056. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45057. */
  45058. useSpecularOverAlpha: boolean;
  45059. /**
  45060. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45061. */
  45062. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45063. /**
  45064. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45065. */
  45066. useRoughnessFromMetallicTextureAlpha: boolean;
  45067. /**
  45068. * Specifies if the metallic texture contains the roughness information in its green channel.
  45069. */
  45070. useRoughnessFromMetallicTextureGreen: boolean;
  45071. /**
  45072. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45073. */
  45074. useMetallnessFromMetallicTextureBlue: boolean;
  45075. /**
  45076. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45077. */
  45078. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45079. /**
  45080. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45081. */
  45082. useAmbientInGrayScale: boolean;
  45083. /**
  45084. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45085. * The material will try to infer what glossiness each pixel should be.
  45086. */
  45087. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45088. /**
  45089. * BJS is using an harcoded light falloff based on a manually sets up range.
  45090. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45091. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45092. */
  45093. /**
  45094. * BJS is using an harcoded light falloff based on a manually sets up range.
  45095. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45096. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45097. */
  45098. usePhysicalLightFalloff: boolean;
  45099. /**
  45100. * In order to support the falloff compatibility with gltf, a special mode has been added
  45101. * to reproduce the gltf light falloff.
  45102. */
  45103. /**
  45104. * In order to support the falloff compatibility with gltf, a special mode has been added
  45105. * to reproduce the gltf light falloff.
  45106. */
  45107. useGLTFLightFalloff: boolean;
  45108. /**
  45109. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45110. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45111. */
  45112. useRadianceOverAlpha: boolean;
  45113. /**
  45114. * Allows using an object space normal map (instead of tangent space).
  45115. */
  45116. useObjectSpaceNormalMap: boolean;
  45117. /**
  45118. * Allows using the bump map in parallax mode.
  45119. */
  45120. useParallax: boolean;
  45121. /**
  45122. * Allows using the bump map in parallax occlusion mode.
  45123. */
  45124. useParallaxOcclusion: boolean;
  45125. /**
  45126. * Controls the scale bias of the parallax mode.
  45127. */
  45128. parallaxScaleBias: number;
  45129. /**
  45130. * If sets to true, disables all the lights affecting the material.
  45131. */
  45132. disableLighting: boolean;
  45133. /**
  45134. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45135. */
  45136. forceIrradianceInFragment: boolean;
  45137. /**
  45138. * Number of Simultaneous lights allowed on the material.
  45139. */
  45140. maxSimultaneousLights: number;
  45141. /**
  45142. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45143. */
  45144. invertNormalMapX: boolean;
  45145. /**
  45146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45147. */
  45148. invertNormalMapY: boolean;
  45149. /**
  45150. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45151. */
  45152. twoSidedLighting: boolean;
  45153. /**
  45154. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45155. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45156. */
  45157. useAlphaFresnel: boolean;
  45158. /**
  45159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45160. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45161. */
  45162. useLinearAlphaFresnel: boolean;
  45163. /**
  45164. * Let user defines the brdf lookup texture used for IBL.
  45165. * A default 8bit version is embedded but you could point at :
  45166. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45167. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45168. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45169. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45170. */
  45171. environmentBRDFTexture: Nullable<BaseTexture>;
  45172. /**
  45173. * Force normal to face away from face.
  45174. */
  45175. forceNormalForward: boolean;
  45176. /**
  45177. * Enables specular anti aliasing in the PBR shader.
  45178. * It will both interacts on the Geometry for analytical and IBL lighting.
  45179. * It also prefilter the roughness map based on the bump values.
  45180. */
  45181. enableSpecularAntiAliasing: boolean;
  45182. /**
  45183. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45184. * makes the reflect vector face the model (under horizon).
  45185. */
  45186. useHorizonOcclusion: boolean;
  45187. /**
  45188. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45189. * too much the area relying on ambient texture to define their ambient occlusion.
  45190. */
  45191. useRadianceOcclusion: boolean;
  45192. /**
  45193. * If set to true, no lighting calculations will be applied.
  45194. */
  45195. unlit: boolean;
  45196. /**
  45197. * Gets the image processing configuration used either in this material.
  45198. */
  45199. /**
  45200. * Sets the Default image processing configuration used either in the this material.
  45201. *
  45202. * If sets to null, the scene one is in use.
  45203. */
  45204. imageProcessingConfiguration: ImageProcessingConfiguration;
  45205. /**
  45206. * Gets wether the color curves effect is enabled.
  45207. */
  45208. /**
  45209. * Sets wether the color curves effect is enabled.
  45210. */
  45211. cameraColorCurvesEnabled: boolean;
  45212. /**
  45213. * Gets wether the color grading effect is enabled.
  45214. */
  45215. /**
  45216. * Gets wether the color grading effect is enabled.
  45217. */
  45218. cameraColorGradingEnabled: boolean;
  45219. /**
  45220. * Gets wether tonemapping is enabled or not.
  45221. */
  45222. /**
  45223. * Sets wether tonemapping is enabled or not
  45224. */
  45225. cameraToneMappingEnabled: boolean;
  45226. /**
  45227. * The camera exposure used on this material.
  45228. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45229. * This corresponds to a photographic exposure.
  45230. */
  45231. /**
  45232. * The camera exposure used on this material.
  45233. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45234. * This corresponds to a photographic exposure.
  45235. */
  45236. cameraExposure: number;
  45237. /**
  45238. * Gets The camera contrast used on this material.
  45239. */
  45240. /**
  45241. * Sets The camera contrast used on this material.
  45242. */
  45243. cameraContrast: number;
  45244. /**
  45245. * Gets the Color Grading 2D Lookup Texture.
  45246. */
  45247. /**
  45248. * Sets the Color Grading 2D Lookup Texture.
  45249. */
  45250. cameraColorGradingTexture: Nullable<BaseTexture>;
  45251. /**
  45252. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45253. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45254. * 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;
  45255. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45256. */
  45257. /**
  45258. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45259. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45260. * 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;
  45261. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45262. */
  45263. cameraColorCurves: Nullable<ColorCurves>;
  45264. /**
  45265. * Instantiates a new PBRMaterial instance.
  45266. *
  45267. * @param name The material name
  45268. * @param scene The scene the material will be use in.
  45269. */
  45270. constructor(name: string, scene: Scene);
  45271. /**
  45272. * Returns the name of this material class.
  45273. */
  45274. getClassName(): string;
  45275. /**
  45276. * Makes a duplicate of the current material.
  45277. * @param name - name to use for the new material.
  45278. */
  45279. clone(name: string): PBRMaterial;
  45280. /**
  45281. * Serializes this PBR Material.
  45282. * @returns - An object with the serialized material.
  45283. */
  45284. serialize(): any;
  45285. /**
  45286. * Parses a PBR Material from a serialized object.
  45287. * @param source - Serialized object.
  45288. * @param scene - BJS scene instance.
  45289. * @param rootUrl - url for the scene object
  45290. * @returns - PBRMaterial
  45291. */
  45292. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45293. }
  45294. }
  45295. declare module BABYLON {
  45296. /**
  45297. * Direct draw surface info
  45298. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45299. */
  45300. export interface DDSInfo {
  45301. /**
  45302. * Width of the texture
  45303. */
  45304. width: number;
  45305. /**
  45306. * Width of the texture
  45307. */
  45308. height: number;
  45309. /**
  45310. * Number of Mipmaps for the texture
  45311. * @see https://en.wikipedia.org/wiki/Mipmap
  45312. */
  45313. mipmapCount: number;
  45314. /**
  45315. * If the textures format is a known fourCC format
  45316. * @see https://www.fourcc.org/
  45317. */
  45318. isFourCC: boolean;
  45319. /**
  45320. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45321. */
  45322. isRGB: boolean;
  45323. /**
  45324. * If the texture is a lumincance format
  45325. */
  45326. isLuminance: boolean;
  45327. /**
  45328. * If this is a cube texture
  45329. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45330. */
  45331. isCube: boolean;
  45332. /**
  45333. * If the texture is a compressed format eg. FOURCC_DXT1
  45334. */
  45335. isCompressed: boolean;
  45336. /**
  45337. * The dxgiFormat of the texture
  45338. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45339. */
  45340. dxgiFormat: number;
  45341. /**
  45342. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45343. */
  45344. textureType: number;
  45345. /**
  45346. * Sphericle polynomial created for the dds texture
  45347. */
  45348. sphericalPolynomial?: SphericalPolynomial;
  45349. }
  45350. /**
  45351. * Class used to provide DDS decompression tools
  45352. */
  45353. export class DDSTools {
  45354. /**
  45355. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45356. */
  45357. static StoreLODInAlphaChannel: boolean;
  45358. /**
  45359. * Gets DDS information from an array buffer
  45360. * @param arrayBuffer defines the array buffer to read data from
  45361. * @returns the DDS information
  45362. */
  45363. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45364. private static _FloatView;
  45365. private static _Int32View;
  45366. private static _ToHalfFloat;
  45367. private static _FromHalfFloat;
  45368. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45369. private static _GetHalfFloatRGBAArrayBuffer;
  45370. private static _GetFloatRGBAArrayBuffer;
  45371. private static _GetFloatAsUIntRGBAArrayBuffer;
  45372. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45373. private static _GetRGBAArrayBuffer;
  45374. private static _ExtractLongWordOrder;
  45375. private static _GetRGBArrayBuffer;
  45376. private static _GetLuminanceArrayBuffer;
  45377. /**
  45378. * Uploads DDS Levels to a Babylon Texture
  45379. * @hidden
  45380. */
  45381. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45382. }
  45383. interface Engine {
  45384. /**
  45385. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45386. * @param rootUrl defines the url where the file to load is located
  45387. * @param scene defines the current scene
  45388. * @param lodScale defines scale to apply to the mip map selection
  45389. * @param lodOffset defines offset to apply to the mip map selection
  45390. * @param onLoad defines an optional callback raised when the texture is loaded
  45391. * @param onError defines an optional callback raised if there is an issue to load the texture
  45392. * @param format defines the format of the data
  45393. * @param forcedExtension defines the extension to use to pick the right loader
  45394. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45395. * @returns the cube texture as an InternalTexture
  45396. */
  45397. 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;
  45398. }
  45399. }
  45400. declare module BABYLON {
  45401. /**
  45402. * Implementation of the DDS Texture Loader.
  45403. * @hidden
  45404. */
  45405. export class _DDSTextureLoader implements IInternalTextureLoader {
  45406. /**
  45407. * Defines wether the loader supports cascade loading the different faces.
  45408. */
  45409. readonly supportCascades: boolean;
  45410. /**
  45411. * This returns if the loader support the current file information.
  45412. * @param extension defines the file extension of the file being loaded
  45413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45414. * @param fallback defines the fallback internal texture if any
  45415. * @param isBase64 defines whether the texture is encoded as a base64
  45416. * @param isBuffer defines whether the texture data are stored as a buffer
  45417. * @returns true if the loader can load the specified file
  45418. */
  45419. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45420. /**
  45421. * Transform the url before loading if required.
  45422. * @param rootUrl the url of the texture
  45423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45424. * @returns the transformed texture
  45425. */
  45426. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45427. /**
  45428. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45429. * @param rootUrl the url of the texture
  45430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45431. * @returns the fallback texture
  45432. */
  45433. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45434. /**
  45435. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45436. * @param data contains the texture data
  45437. * @param texture defines the BabylonJS internal texture
  45438. * @param createPolynomials will be true if polynomials have been requested
  45439. * @param onLoad defines the callback to trigger once the texture is ready
  45440. * @param onError defines the callback to trigger in case of error
  45441. */
  45442. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45443. /**
  45444. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45445. * @param data contains the texture data
  45446. * @param texture defines the BabylonJS internal texture
  45447. * @param callback defines the method to call once ready to upload
  45448. */
  45449. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45450. }
  45451. }
  45452. declare module BABYLON {
  45453. /** @hidden */
  45454. export var rgbdEncodePixelShader: {
  45455. name: string;
  45456. shader: string;
  45457. };
  45458. }
  45459. declare module BABYLON {
  45460. /**
  45461. * Raw texture data and descriptor sufficient for WebGL texture upload
  45462. */
  45463. export interface EnvironmentTextureInfo {
  45464. /**
  45465. * Version of the environment map
  45466. */
  45467. version: number;
  45468. /**
  45469. * Width of image
  45470. */
  45471. width: number;
  45472. /**
  45473. * Irradiance information stored in the file.
  45474. */
  45475. irradiance: any;
  45476. /**
  45477. * Specular information stored in the file.
  45478. */
  45479. specular: any;
  45480. }
  45481. /**
  45482. * Sets of helpers addressing the serialization and deserialization of environment texture
  45483. * stored in a BabylonJS env file.
  45484. * Those files are usually stored as .env files.
  45485. */
  45486. export class EnvironmentTextureTools {
  45487. /**
  45488. * Magic number identifying the env file.
  45489. */
  45490. private static _MagicBytes;
  45491. /**
  45492. * Gets the environment info from an env file.
  45493. * @param data The array buffer containing the .env bytes.
  45494. * @returns the environment file info (the json header) if successfully parsed.
  45495. */
  45496. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45497. /**
  45498. * Creates an environment texture from a loaded cube texture.
  45499. * @param texture defines the cube texture to convert in env file
  45500. * @return a promise containing the environment data if succesfull.
  45501. */
  45502. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45503. /**
  45504. * Creates a JSON representation of the spherical data.
  45505. * @param texture defines the texture containing the polynomials
  45506. * @return the JSON representation of the spherical info
  45507. */
  45508. private static _CreateEnvTextureIrradiance;
  45509. /**
  45510. * Uploads the texture info contained in the env file to the GPU.
  45511. * @param texture defines the internal texture to upload to
  45512. * @param arrayBuffer defines the buffer cotaining the data to load
  45513. * @param info defines the texture info retrieved through the GetEnvInfo method
  45514. * @returns a promise
  45515. */
  45516. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45517. /**
  45518. * Uploads the levels of image data to the GPU.
  45519. * @param texture defines the internal texture to upload to
  45520. * @param imageData defines the array buffer views of image data [mipmap][face]
  45521. * @returns a promise
  45522. */
  45523. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45524. /**
  45525. * Uploads spherical polynomials information to the texture.
  45526. * @param texture defines the texture we are trying to upload the information to
  45527. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45528. */
  45529. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45530. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45531. }
  45532. }
  45533. declare module BABYLON {
  45534. /**
  45535. * Implementation of the ENV Texture Loader.
  45536. * @hidden
  45537. */
  45538. export class _ENVTextureLoader implements IInternalTextureLoader {
  45539. /**
  45540. * Defines wether the loader supports cascade loading the different faces.
  45541. */
  45542. readonly supportCascades: boolean;
  45543. /**
  45544. * This returns if the loader support the current file information.
  45545. * @param extension defines the file extension of the file being loaded
  45546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45547. * @param fallback defines the fallback internal texture if any
  45548. * @param isBase64 defines whether the texture is encoded as a base64
  45549. * @param isBuffer defines whether the texture data are stored as a buffer
  45550. * @returns true if the loader can load the specified file
  45551. */
  45552. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45553. /**
  45554. * Transform the url before loading if required.
  45555. * @param rootUrl the url of the texture
  45556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45557. * @returns the transformed texture
  45558. */
  45559. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45560. /**
  45561. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45562. * @param rootUrl the url of the texture
  45563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45564. * @returns the fallback texture
  45565. */
  45566. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45567. /**
  45568. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45569. * @param data contains the texture data
  45570. * @param texture defines the BabylonJS internal texture
  45571. * @param createPolynomials will be true if polynomials have been requested
  45572. * @param onLoad defines the callback to trigger once the texture is ready
  45573. * @param onError defines the callback to trigger in case of error
  45574. */
  45575. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45576. /**
  45577. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45578. * @param data contains the texture data
  45579. * @param texture defines the BabylonJS internal texture
  45580. * @param callback defines the method to call once ready to upload
  45581. */
  45582. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45583. }
  45584. }
  45585. declare module BABYLON {
  45586. /**
  45587. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45588. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45589. */
  45590. export class KhronosTextureContainer {
  45591. /** contents of the KTX container file */
  45592. arrayBuffer: any;
  45593. private static HEADER_LEN;
  45594. private static COMPRESSED_2D;
  45595. private static COMPRESSED_3D;
  45596. private static TEX_2D;
  45597. private static TEX_3D;
  45598. /**
  45599. * Gets the openGL type
  45600. */
  45601. glType: number;
  45602. /**
  45603. * Gets the openGL type size
  45604. */
  45605. glTypeSize: number;
  45606. /**
  45607. * Gets the openGL format
  45608. */
  45609. glFormat: number;
  45610. /**
  45611. * Gets the openGL internal format
  45612. */
  45613. glInternalFormat: number;
  45614. /**
  45615. * Gets the base internal format
  45616. */
  45617. glBaseInternalFormat: number;
  45618. /**
  45619. * Gets image width in pixel
  45620. */
  45621. pixelWidth: number;
  45622. /**
  45623. * Gets image height in pixel
  45624. */
  45625. pixelHeight: number;
  45626. /**
  45627. * Gets image depth in pixels
  45628. */
  45629. pixelDepth: number;
  45630. /**
  45631. * Gets the number of array elements
  45632. */
  45633. numberOfArrayElements: number;
  45634. /**
  45635. * Gets the number of faces
  45636. */
  45637. numberOfFaces: number;
  45638. /**
  45639. * Gets the number of mipmap levels
  45640. */
  45641. numberOfMipmapLevels: number;
  45642. /**
  45643. * Gets the bytes of key value data
  45644. */
  45645. bytesOfKeyValueData: number;
  45646. /**
  45647. * Gets the load type
  45648. */
  45649. loadType: number;
  45650. /**
  45651. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45652. */
  45653. isInvalid: boolean;
  45654. /**
  45655. * Creates a new KhronosTextureContainer
  45656. * @param arrayBuffer contents of the KTX container file
  45657. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45658. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45659. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45660. */
  45661. constructor(
  45662. /** contents of the KTX container file */
  45663. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45664. /**
  45665. * Uploads KTX content to a Babylon Texture.
  45666. * It is assumed that the texture has already been created & is currently bound
  45667. * @hidden
  45668. */
  45669. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45670. private _upload2DCompressedLevels;
  45671. }
  45672. }
  45673. declare module BABYLON {
  45674. /**
  45675. * Implementation of the KTX Texture Loader.
  45676. * @hidden
  45677. */
  45678. export class _KTXTextureLoader implements IInternalTextureLoader {
  45679. /**
  45680. * Defines wether the loader supports cascade loading the different faces.
  45681. */
  45682. readonly supportCascades: boolean;
  45683. /**
  45684. * This returns if the loader support the current file information.
  45685. * @param extension defines the file extension of the file being loaded
  45686. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45687. * @param fallback defines the fallback internal texture if any
  45688. * @param isBase64 defines whether the texture is encoded as a base64
  45689. * @param isBuffer defines whether the texture data are stored as a buffer
  45690. * @returns true if the loader can load the specified file
  45691. */
  45692. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45693. /**
  45694. * Transform the url before loading if required.
  45695. * @param rootUrl the url of the texture
  45696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45697. * @returns the transformed texture
  45698. */
  45699. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45700. /**
  45701. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45702. * @param rootUrl the url of the texture
  45703. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45704. * @returns the fallback texture
  45705. */
  45706. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45707. /**
  45708. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45709. * @param data contains the texture data
  45710. * @param texture defines the BabylonJS internal texture
  45711. * @param createPolynomials will be true if polynomials have been requested
  45712. * @param onLoad defines the callback to trigger once the texture is ready
  45713. * @param onError defines the callback to trigger in case of error
  45714. */
  45715. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45716. /**
  45717. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45718. * @param data contains the texture data
  45719. * @param texture defines the BabylonJS internal texture
  45720. * @param callback defines the method to call once ready to upload
  45721. */
  45722. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45723. }
  45724. }
  45725. declare module BABYLON {
  45726. /** @hidden */
  45727. export var _forceSceneHelpersToBundle: boolean;
  45728. interface Scene {
  45729. /**
  45730. * Creates a default light for the scene.
  45731. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45732. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45733. */
  45734. createDefaultLight(replace?: boolean): void;
  45735. /**
  45736. * Creates a default camera for the scene.
  45737. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45738. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45739. * @param replace has default false, when true replaces the active camera in the scene
  45740. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45741. */
  45742. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45743. /**
  45744. * Creates a default camera and a default light.
  45745. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45746. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45747. * @param replace has the default false, when true replaces the active camera/light in the scene
  45748. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45749. */
  45750. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45751. /**
  45752. * Creates a new sky box
  45753. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45754. * @param environmentTexture defines the texture to use as environment texture
  45755. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45756. * @param scale defines the overall scale of the skybox
  45757. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45758. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45759. * @returns a new mesh holding the sky box
  45760. */
  45761. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45762. /**
  45763. * Creates a new environment
  45764. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45765. * @param options defines the options you can use to configure the environment
  45766. * @returns the new EnvironmentHelper
  45767. */
  45768. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45769. /**
  45770. * Creates a new VREXperienceHelper
  45771. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45772. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45773. * @returns a new VREXperienceHelper
  45774. */
  45775. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45776. /**
  45777. * Creates a new XREXperienceHelper
  45778. * @see http://doc.babylonjs.com/how_to/webxr
  45779. * @returns a promise for a new XREXperienceHelper
  45780. */
  45781. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45782. }
  45783. }
  45784. declare module BABYLON {
  45785. /**
  45786. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45787. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45788. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45789. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45790. */
  45791. export class VideoDome extends TransformNode {
  45792. /**
  45793. * Define the video source as a Monoscopic panoramic 360 video.
  45794. */
  45795. static readonly MODE_MONOSCOPIC: number;
  45796. /**
  45797. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45798. */
  45799. static readonly MODE_TOPBOTTOM: number;
  45800. /**
  45801. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45802. */
  45803. static readonly MODE_SIDEBYSIDE: number;
  45804. private _useDirectMapping;
  45805. /**
  45806. * The video texture being displayed on the sphere
  45807. */
  45808. protected _videoTexture: VideoTexture;
  45809. /**
  45810. * Gets the video texture being displayed on the sphere
  45811. */
  45812. readonly videoTexture: VideoTexture;
  45813. /**
  45814. * The skybox material
  45815. */
  45816. protected _material: BackgroundMaterial;
  45817. /**
  45818. * The surface used for the skybox
  45819. */
  45820. protected _mesh: Mesh;
  45821. /**
  45822. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45823. * Also see the options.resolution property.
  45824. */
  45825. fovMultiplier: number;
  45826. private _videoMode;
  45827. /**
  45828. * Gets or set the current video mode for the video. It can be:
  45829. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45830. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45831. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45832. */
  45833. videoMode: number;
  45834. /**
  45835. * Oberserver used in Stereoscopic VR Mode.
  45836. */
  45837. private _onBeforeCameraRenderObserver;
  45838. /**
  45839. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45840. * @param name Element's name, child elements will append suffixes for their own names.
  45841. * @param urlsOrVideo defines the url(s) or the video element to use
  45842. * @param options An object containing optional or exposed sub element properties
  45843. */
  45844. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45845. resolution?: number;
  45846. clickToPlay?: boolean;
  45847. autoPlay?: boolean;
  45848. loop?: boolean;
  45849. size?: number;
  45850. poster?: string;
  45851. faceForward?: boolean;
  45852. useDirectMapping?: boolean;
  45853. }, scene: Scene);
  45854. private _changeVideoMode;
  45855. /**
  45856. * Releases resources associated with this node.
  45857. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45858. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45859. */
  45860. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45861. }
  45862. }
  45863. declare module BABYLON {
  45864. /**
  45865. * This class can be used to get instrumentation data from a Babylon engine
  45866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45867. */
  45868. export class EngineInstrumentation implements IDisposable {
  45869. /**
  45870. * Define the instrumented engine.
  45871. */
  45872. engine: Engine;
  45873. private _captureGPUFrameTime;
  45874. private _gpuFrameTimeToken;
  45875. private _gpuFrameTime;
  45876. private _captureShaderCompilationTime;
  45877. private _shaderCompilationTime;
  45878. private _onBeginFrameObserver;
  45879. private _onEndFrameObserver;
  45880. private _onBeforeShaderCompilationObserver;
  45881. private _onAfterShaderCompilationObserver;
  45882. /**
  45883. * Gets the perf counter used for GPU frame time
  45884. */
  45885. readonly gpuFrameTimeCounter: PerfCounter;
  45886. /**
  45887. * Gets the GPU frame time capture status
  45888. */
  45889. /**
  45890. * Enable or disable the GPU frame time capture
  45891. */
  45892. captureGPUFrameTime: boolean;
  45893. /**
  45894. * Gets the perf counter used for shader compilation time
  45895. */
  45896. readonly shaderCompilationTimeCounter: PerfCounter;
  45897. /**
  45898. * Gets the shader compilation time capture status
  45899. */
  45900. /**
  45901. * Enable or disable the shader compilation time capture
  45902. */
  45903. captureShaderCompilationTime: boolean;
  45904. /**
  45905. * Instantiates a new engine instrumentation.
  45906. * This class can be used to get instrumentation data from a Babylon engine
  45907. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45908. * @param engine Defines the engine to instrument
  45909. */
  45910. constructor(
  45911. /**
  45912. * Define the instrumented engine.
  45913. */
  45914. engine: Engine);
  45915. /**
  45916. * Dispose and release associated resources.
  45917. */
  45918. dispose(): void;
  45919. }
  45920. }
  45921. declare module BABYLON {
  45922. /**
  45923. * This class can be used to get instrumentation data from a Babylon engine
  45924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45925. */
  45926. export class SceneInstrumentation implements IDisposable {
  45927. /**
  45928. * Defines the scene to instrument
  45929. */
  45930. scene: Scene;
  45931. private _captureActiveMeshesEvaluationTime;
  45932. private _activeMeshesEvaluationTime;
  45933. private _captureRenderTargetsRenderTime;
  45934. private _renderTargetsRenderTime;
  45935. private _captureFrameTime;
  45936. private _frameTime;
  45937. private _captureRenderTime;
  45938. private _renderTime;
  45939. private _captureInterFrameTime;
  45940. private _interFrameTime;
  45941. private _captureParticlesRenderTime;
  45942. private _particlesRenderTime;
  45943. private _captureSpritesRenderTime;
  45944. private _spritesRenderTime;
  45945. private _capturePhysicsTime;
  45946. private _physicsTime;
  45947. private _captureAnimationsTime;
  45948. private _animationsTime;
  45949. private _captureCameraRenderTime;
  45950. private _cameraRenderTime;
  45951. private _onBeforeActiveMeshesEvaluationObserver;
  45952. private _onAfterActiveMeshesEvaluationObserver;
  45953. private _onBeforeRenderTargetsRenderObserver;
  45954. private _onAfterRenderTargetsRenderObserver;
  45955. private _onAfterRenderObserver;
  45956. private _onBeforeDrawPhaseObserver;
  45957. private _onAfterDrawPhaseObserver;
  45958. private _onBeforeAnimationsObserver;
  45959. private _onBeforeParticlesRenderingObserver;
  45960. private _onAfterParticlesRenderingObserver;
  45961. private _onBeforeSpritesRenderingObserver;
  45962. private _onAfterSpritesRenderingObserver;
  45963. private _onBeforePhysicsObserver;
  45964. private _onAfterPhysicsObserver;
  45965. private _onAfterAnimationsObserver;
  45966. private _onBeforeCameraRenderObserver;
  45967. private _onAfterCameraRenderObserver;
  45968. /**
  45969. * Gets the perf counter used for active meshes evaluation time
  45970. */
  45971. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45972. /**
  45973. * Gets the active meshes evaluation time capture status
  45974. */
  45975. /**
  45976. * Enable or disable the active meshes evaluation time capture
  45977. */
  45978. captureActiveMeshesEvaluationTime: boolean;
  45979. /**
  45980. * Gets the perf counter used for render targets render time
  45981. */
  45982. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45983. /**
  45984. * Gets the render targets render time capture status
  45985. */
  45986. /**
  45987. * Enable or disable the render targets render time capture
  45988. */
  45989. captureRenderTargetsRenderTime: boolean;
  45990. /**
  45991. * Gets the perf counter used for particles render time
  45992. */
  45993. readonly particlesRenderTimeCounter: PerfCounter;
  45994. /**
  45995. * Gets the particles render time capture status
  45996. */
  45997. /**
  45998. * Enable or disable the particles render time capture
  45999. */
  46000. captureParticlesRenderTime: boolean;
  46001. /**
  46002. * Gets the perf counter used for sprites render time
  46003. */
  46004. readonly spritesRenderTimeCounter: PerfCounter;
  46005. /**
  46006. * Gets the sprites render time capture status
  46007. */
  46008. /**
  46009. * Enable or disable the sprites render time capture
  46010. */
  46011. captureSpritesRenderTime: boolean;
  46012. /**
  46013. * Gets the perf counter used for physics time
  46014. */
  46015. readonly physicsTimeCounter: PerfCounter;
  46016. /**
  46017. * Gets the physics time capture status
  46018. */
  46019. /**
  46020. * Enable or disable the physics time capture
  46021. */
  46022. capturePhysicsTime: boolean;
  46023. /**
  46024. * Gets the perf counter used for animations time
  46025. */
  46026. readonly animationsTimeCounter: PerfCounter;
  46027. /**
  46028. * Gets the animations time capture status
  46029. */
  46030. /**
  46031. * Enable or disable the animations time capture
  46032. */
  46033. captureAnimationsTime: boolean;
  46034. /**
  46035. * Gets the perf counter used for frame time capture
  46036. */
  46037. readonly frameTimeCounter: PerfCounter;
  46038. /**
  46039. * Gets the frame time capture status
  46040. */
  46041. /**
  46042. * Enable or disable the frame time capture
  46043. */
  46044. captureFrameTime: boolean;
  46045. /**
  46046. * Gets the perf counter used for inter-frames time capture
  46047. */
  46048. readonly interFrameTimeCounter: PerfCounter;
  46049. /**
  46050. * Gets the inter-frames time capture status
  46051. */
  46052. /**
  46053. * Enable or disable the inter-frames time capture
  46054. */
  46055. captureInterFrameTime: boolean;
  46056. /**
  46057. * Gets the perf counter used for render time capture
  46058. */
  46059. readonly renderTimeCounter: PerfCounter;
  46060. /**
  46061. * Gets the render time capture status
  46062. */
  46063. /**
  46064. * Enable or disable the render time capture
  46065. */
  46066. captureRenderTime: boolean;
  46067. /**
  46068. * Gets the perf counter used for camera render time capture
  46069. */
  46070. readonly cameraRenderTimeCounter: PerfCounter;
  46071. /**
  46072. * Gets the camera render time capture status
  46073. */
  46074. /**
  46075. * Enable or disable the camera render time capture
  46076. */
  46077. captureCameraRenderTime: boolean;
  46078. /**
  46079. * Gets the perf counter used for draw calls
  46080. */
  46081. readonly drawCallsCounter: PerfCounter;
  46082. /**
  46083. * Instantiates a new scene instrumentation.
  46084. * This class can be used to get instrumentation data from a Babylon engine
  46085. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46086. * @param scene Defines the scene to instrument
  46087. */
  46088. constructor(
  46089. /**
  46090. * Defines the scene to instrument
  46091. */
  46092. scene: Scene);
  46093. /**
  46094. * Dispose and release associated resources.
  46095. */
  46096. dispose(): void;
  46097. }
  46098. }
  46099. declare module BABYLON {
  46100. /** @hidden */
  46101. export var glowMapGenerationPixelShader: {
  46102. name: string;
  46103. shader: string;
  46104. };
  46105. }
  46106. declare module BABYLON {
  46107. /** @hidden */
  46108. export var glowMapGenerationVertexShader: {
  46109. name: string;
  46110. shader: string;
  46111. };
  46112. }
  46113. declare module BABYLON {
  46114. /**
  46115. * Effect layer options. This helps customizing the behaviour
  46116. * of the effect layer.
  46117. */
  46118. export interface IEffectLayerOptions {
  46119. /**
  46120. * Multiplication factor apply to the canvas size to compute the render target size
  46121. * used to generated the objects (the smaller the faster).
  46122. */
  46123. mainTextureRatio: number;
  46124. /**
  46125. * Enforces a fixed size texture to ensure effect stability across devices.
  46126. */
  46127. mainTextureFixedSize?: number;
  46128. /**
  46129. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46130. */
  46131. alphaBlendingMode: number;
  46132. /**
  46133. * The camera attached to the layer.
  46134. */
  46135. camera: Nullable<Camera>;
  46136. /**
  46137. * The rendering group to draw the layer in.
  46138. */
  46139. renderingGroupId: number;
  46140. }
  46141. /**
  46142. * The effect layer Helps adding post process effect blended with the main pass.
  46143. *
  46144. * This can be for instance use to generate glow or higlight effects on the scene.
  46145. *
  46146. * The effect layer class can not be used directly and is intented to inherited from to be
  46147. * customized per effects.
  46148. */
  46149. export abstract class EffectLayer {
  46150. private _vertexBuffers;
  46151. private _indexBuffer;
  46152. private _cachedDefines;
  46153. private _effectLayerMapGenerationEffect;
  46154. private _effectLayerOptions;
  46155. private _mergeEffect;
  46156. protected _scene: Scene;
  46157. protected _engine: Engine;
  46158. protected _maxSize: number;
  46159. protected _mainTextureDesiredSize: ISize;
  46160. protected _mainTexture: RenderTargetTexture;
  46161. protected _shouldRender: boolean;
  46162. protected _postProcesses: PostProcess[];
  46163. protected _textures: BaseTexture[];
  46164. protected _emissiveTextureAndColor: {
  46165. texture: Nullable<BaseTexture>;
  46166. color: Color4;
  46167. };
  46168. /**
  46169. * The name of the layer
  46170. */
  46171. name: string;
  46172. /**
  46173. * The clear color of the texture used to generate the glow map.
  46174. */
  46175. neutralColor: Color4;
  46176. /**
  46177. * Specifies wether the highlight layer is enabled or not.
  46178. */
  46179. isEnabled: boolean;
  46180. /**
  46181. * Gets the camera attached to the layer.
  46182. */
  46183. readonly camera: Nullable<Camera>;
  46184. /**
  46185. * Gets the rendering group id the layer should render in.
  46186. */
  46187. readonly renderingGroupId: number;
  46188. /**
  46189. * An event triggered when the effect layer has been disposed.
  46190. */
  46191. onDisposeObservable: Observable<EffectLayer>;
  46192. /**
  46193. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46194. */
  46195. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46196. /**
  46197. * An event triggered when the generated texture is being merged in the scene.
  46198. */
  46199. onBeforeComposeObservable: Observable<EffectLayer>;
  46200. /**
  46201. * An event triggered when the generated texture has been merged in the scene.
  46202. */
  46203. onAfterComposeObservable: Observable<EffectLayer>;
  46204. /**
  46205. * An event triggered when the efffect layer changes its size.
  46206. */
  46207. onSizeChangedObservable: Observable<EffectLayer>;
  46208. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46209. /**
  46210. * Instantiates a new effect Layer and references it in the scene.
  46211. * @param name The name of the layer
  46212. * @param scene The scene to use the layer in
  46213. */
  46214. constructor(
  46215. /** The Friendly of the effect in the scene */
  46216. name: string, scene: Scene);
  46217. /**
  46218. * Get the effect name of the layer.
  46219. * @return The effect name
  46220. */
  46221. abstract getEffectName(): string;
  46222. /**
  46223. * Checks for the readiness of the element composing the layer.
  46224. * @param subMesh the mesh to check for
  46225. * @param useInstances specify wether or not to use instances to render the mesh
  46226. * @return true if ready otherwise, false
  46227. */
  46228. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46229. /**
  46230. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46231. * @returns true if the effect requires stencil during the main canvas render pass.
  46232. */
  46233. abstract needStencil(): boolean;
  46234. /**
  46235. * Create the merge effect. This is the shader use to blit the information back
  46236. * to the main canvas at the end of the scene rendering.
  46237. * @returns The effect containing the shader used to merge the effect on the main canvas
  46238. */
  46239. protected abstract _createMergeEffect(): Effect;
  46240. /**
  46241. * Creates the render target textures and post processes used in the effect layer.
  46242. */
  46243. protected abstract _createTextureAndPostProcesses(): void;
  46244. /**
  46245. * Implementation specific of rendering the generating effect on the main canvas.
  46246. * @param effect The effect used to render through
  46247. */
  46248. protected abstract _internalRender(effect: Effect): void;
  46249. /**
  46250. * Sets the required values for both the emissive texture and and the main color.
  46251. */
  46252. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46253. /**
  46254. * Free any resources and references associated to a mesh.
  46255. * Internal use
  46256. * @param mesh The mesh to free.
  46257. */
  46258. abstract _disposeMesh(mesh: Mesh): void;
  46259. /**
  46260. * Serializes this layer (Glow or Highlight for example)
  46261. * @returns a serialized layer object
  46262. */
  46263. abstract serialize?(): any;
  46264. /**
  46265. * Initializes the effect layer with the required options.
  46266. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46267. */
  46268. protected _init(options: Partial<IEffectLayerOptions>): void;
  46269. /**
  46270. * Generates the index buffer of the full screen quad blending to the main canvas.
  46271. */
  46272. private _generateIndexBuffer;
  46273. /**
  46274. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46275. */
  46276. private _generateVertexBuffer;
  46277. /**
  46278. * Sets the main texture desired size which is the closest power of two
  46279. * of the engine canvas size.
  46280. */
  46281. private _setMainTextureSize;
  46282. /**
  46283. * Creates the main texture for the effect layer.
  46284. */
  46285. protected _createMainTexture(): void;
  46286. /**
  46287. * Adds specific effects defines.
  46288. * @param defines The defines to add specifics to.
  46289. */
  46290. protected _addCustomEffectDefines(defines: string[]): void;
  46291. /**
  46292. * Checks for the readiness of the element composing the layer.
  46293. * @param subMesh the mesh to check for
  46294. * @param useInstances specify wether or not to use instances to render the mesh
  46295. * @param emissiveTexture the associated emissive texture used to generate the glow
  46296. * @return true if ready otherwise, false
  46297. */
  46298. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46299. /**
  46300. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46301. */
  46302. render(): void;
  46303. /**
  46304. * Determine if a given mesh will be used in the current effect.
  46305. * @param mesh mesh to test
  46306. * @returns true if the mesh will be used
  46307. */
  46308. hasMesh(mesh: AbstractMesh): boolean;
  46309. /**
  46310. * Returns true if the layer contains information to display, otherwise false.
  46311. * @returns true if the glow layer should be rendered
  46312. */
  46313. shouldRender(): boolean;
  46314. /**
  46315. * Returns true if the mesh should render, otherwise false.
  46316. * @param mesh The mesh to render
  46317. * @returns true if it should render otherwise false
  46318. */
  46319. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46320. /**
  46321. * Returns true if the mesh can be rendered, otherwise false.
  46322. * @param mesh The mesh to render
  46323. * @param material The material used on the mesh
  46324. * @returns true if it can be rendered otherwise false
  46325. */
  46326. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46327. /**
  46328. * Returns true if the mesh should render, otherwise false.
  46329. * @param mesh The mesh to render
  46330. * @returns true if it should render otherwise false
  46331. */
  46332. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46333. /**
  46334. * Renders the submesh passed in parameter to the generation map.
  46335. */
  46336. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46337. /**
  46338. * Rebuild the required buffers.
  46339. * @hidden Internal use only.
  46340. */ private _rebuild(): void;
  46341. /**
  46342. * Dispose only the render target textures and post process.
  46343. */
  46344. private _disposeTextureAndPostProcesses;
  46345. /**
  46346. * Dispose the highlight layer and free resources.
  46347. */
  46348. dispose(): void;
  46349. /**
  46350. * Gets the class name of the effect layer
  46351. * @returns the string with the class name of the effect layer
  46352. */
  46353. getClassName(): string;
  46354. /**
  46355. * Creates an effect layer from parsed effect layer data
  46356. * @param parsedEffectLayer defines effect layer data
  46357. * @param scene defines the current scene
  46358. * @param rootUrl defines the root URL containing the effect layer information
  46359. * @returns a parsed effect Layer
  46360. */
  46361. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46362. }
  46363. }
  46364. declare module BABYLON {
  46365. interface AbstractScene {
  46366. /**
  46367. * The list of effect layers (highlights/glow) added to the scene
  46368. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46369. * @see http://doc.babylonjs.com/how_to/glow_layer
  46370. */
  46371. effectLayers: Array<EffectLayer>;
  46372. /**
  46373. * Removes the given effect layer from this scene.
  46374. * @param toRemove defines the effect layer to remove
  46375. * @returns the index of the removed effect layer
  46376. */
  46377. removeEffectLayer(toRemove: EffectLayer): number;
  46378. /**
  46379. * Adds the given effect layer to this scene
  46380. * @param newEffectLayer defines the effect layer to add
  46381. */
  46382. addEffectLayer(newEffectLayer: EffectLayer): void;
  46383. }
  46384. /**
  46385. * Defines the layer scene component responsible to manage any effect layers
  46386. * in a given scene.
  46387. */
  46388. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46389. /**
  46390. * The component name helpfull to identify the component in the list of scene components.
  46391. */
  46392. readonly name: string;
  46393. /**
  46394. * The scene the component belongs to.
  46395. */
  46396. scene: Scene;
  46397. private _engine;
  46398. private _renderEffects;
  46399. private _needStencil;
  46400. private _previousStencilState;
  46401. /**
  46402. * Creates a new instance of the component for the given scene
  46403. * @param scene Defines the scene to register the component in
  46404. */
  46405. constructor(scene: Scene);
  46406. /**
  46407. * Registers the component in a given scene
  46408. */
  46409. register(): void;
  46410. /**
  46411. * Rebuilds the elements related to this component in case of
  46412. * context lost for instance.
  46413. */
  46414. rebuild(): void;
  46415. /**
  46416. * Serializes the component data to the specified json object
  46417. * @param serializationObject The object to serialize to
  46418. */
  46419. serialize(serializationObject: any): void;
  46420. /**
  46421. * Adds all the element from the container to the scene
  46422. * @param container the container holding the elements
  46423. */
  46424. addFromContainer(container: AbstractScene): void;
  46425. /**
  46426. * Removes all the elements in the container from the scene
  46427. * @param container contains the elements to remove
  46428. * @param dispose if the removed element should be disposed (default: false)
  46429. */
  46430. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46431. /**
  46432. * Disposes the component and the associated ressources.
  46433. */
  46434. dispose(): void;
  46435. private _isReadyForMesh;
  46436. private _renderMainTexture;
  46437. private _setStencil;
  46438. private _setStencilBack;
  46439. private _draw;
  46440. private _drawCamera;
  46441. private _drawRenderingGroup;
  46442. }
  46443. }
  46444. declare module BABYLON {
  46445. /** @hidden */
  46446. export var glowMapMergePixelShader: {
  46447. name: string;
  46448. shader: string;
  46449. };
  46450. }
  46451. declare module BABYLON {
  46452. /** @hidden */
  46453. export var glowMapMergeVertexShader: {
  46454. name: string;
  46455. shader: string;
  46456. };
  46457. }
  46458. declare module BABYLON {
  46459. interface AbstractScene {
  46460. /**
  46461. * Return a the first highlight layer of the scene with a given name.
  46462. * @param name The name of the highlight layer to look for.
  46463. * @return The highlight layer if found otherwise null.
  46464. */
  46465. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46466. }
  46467. /**
  46468. * Glow layer options. This helps customizing the behaviour
  46469. * of the glow layer.
  46470. */
  46471. export interface IGlowLayerOptions {
  46472. /**
  46473. * Multiplication factor apply to the canvas size to compute the render target size
  46474. * used to generated the glowing objects (the smaller the faster).
  46475. */
  46476. mainTextureRatio: number;
  46477. /**
  46478. * Enforces a fixed size texture to ensure resize independant blur.
  46479. */
  46480. mainTextureFixedSize?: number;
  46481. /**
  46482. * How big is the kernel of the blur texture.
  46483. */
  46484. blurKernelSize: number;
  46485. /**
  46486. * The camera attached to the layer.
  46487. */
  46488. camera: Nullable<Camera>;
  46489. /**
  46490. * Enable MSAA by chosing the number of samples.
  46491. */
  46492. mainTextureSamples?: number;
  46493. /**
  46494. * The rendering group to draw the layer in.
  46495. */
  46496. renderingGroupId: number;
  46497. }
  46498. /**
  46499. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46500. *
  46501. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46502. * glowy meshes to your scene.
  46503. *
  46504. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46505. */
  46506. export class GlowLayer extends EffectLayer {
  46507. /**
  46508. * Effect Name of the layer.
  46509. */
  46510. static readonly EffectName: string;
  46511. /**
  46512. * The default blur kernel size used for the glow.
  46513. */
  46514. static DefaultBlurKernelSize: number;
  46515. /**
  46516. * The default texture size ratio used for the glow.
  46517. */
  46518. static DefaultTextureRatio: number;
  46519. /**
  46520. * Sets the kernel size of the blur.
  46521. */
  46522. /**
  46523. * Gets the kernel size of the blur.
  46524. */
  46525. blurKernelSize: number;
  46526. /**
  46527. * Sets the glow intensity.
  46528. */
  46529. /**
  46530. * Gets the glow intensity.
  46531. */
  46532. intensity: number;
  46533. private _options;
  46534. private _intensity;
  46535. private _horizontalBlurPostprocess1;
  46536. private _verticalBlurPostprocess1;
  46537. private _horizontalBlurPostprocess2;
  46538. private _verticalBlurPostprocess2;
  46539. private _blurTexture1;
  46540. private _blurTexture2;
  46541. private _postProcesses1;
  46542. private _postProcesses2;
  46543. private _includedOnlyMeshes;
  46544. private _excludedMeshes;
  46545. /**
  46546. * Callback used to let the user override the color selection on a per mesh basis
  46547. */
  46548. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46549. /**
  46550. * Callback used to let the user override the texture selection on a per mesh basis
  46551. */
  46552. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46553. /**
  46554. * Instantiates a new glow Layer and references it to the scene.
  46555. * @param name The name of the layer
  46556. * @param scene The scene to use the layer in
  46557. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46558. */
  46559. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46560. /**
  46561. * Get the effect name of the layer.
  46562. * @return The effect name
  46563. */
  46564. getEffectName(): string;
  46565. /**
  46566. * Create the merge effect. This is the shader use to blit the information back
  46567. * to the main canvas at the end of the scene rendering.
  46568. */
  46569. protected _createMergeEffect(): Effect;
  46570. /**
  46571. * Creates the render target textures and post processes used in the glow layer.
  46572. */
  46573. protected _createTextureAndPostProcesses(): void;
  46574. /**
  46575. * Checks for the readiness of the element composing the layer.
  46576. * @param subMesh the mesh to check for
  46577. * @param useInstances specify wether or not to use instances to render the mesh
  46578. * @param emissiveTexture the associated emissive texture used to generate the glow
  46579. * @return true if ready otherwise, false
  46580. */
  46581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46582. /**
  46583. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46584. */
  46585. needStencil(): boolean;
  46586. /**
  46587. * Returns true if the mesh can be rendered, otherwise false.
  46588. * @param mesh The mesh to render
  46589. * @param material The material used on the mesh
  46590. * @returns true if it can be rendered otherwise false
  46591. */
  46592. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46593. /**
  46594. * Implementation specific of rendering the generating effect on the main canvas.
  46595. * @param effect The effect used to render through
  46596. */
  46597. protected _internalRender(effect: Effect): void;
  46598. /**
  46599. * Sets the required values for both the emissive texture and and the main color.
  46600. */
  46601. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46602. /**
  46603. * Returns true if the mesh should render, otherwise false.
  46604. * @param mesh The mesh to render
  46605. * @returns true if it should render otherwise false
  46606. */
  46607. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46608. /**
  46609. * Adds specific effects defines.
  46610. * @param defines The defines to add specifics to.
  46611. */
  46612. protected _addCustomEffectDefines(defines: string[]): void;
  46613. /**
  46614. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46615. * @param mesh The mesh to exclude from the glow layer
  46616. */
  46617. addExcludedMesh(mesh: Mesh): void;
  46618. /**
  46619. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46620. * @param mesh The mesh to remove
  46621. */
  46622. removeExcludedMesh(mesh: Mesh): void;
  46623. /**
  46624. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46625. * @param mesh The mesh to include in the glow layer
  46626. */
  46627. addIncludedOnlyMesh(mesh: Mesh): void;
  46628. /**
  46629. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46630. * @param mesh The mesh to remove
  46631. */
  46632. removeIncludedOnlyMesh(mesh: Mesh): void;
  46633. /**
  46634. * Determine if a given mesh will be used in the glow layer
  46635. * @param mesh The mesh to test
  46636. * @returns true if the mesh will be highlighted by the current glow layer
  46637. */
  46638. hasMesh(mesh: AbstractMesh): boolean;
  46639. /**
  46640. * Free any resources and references associated to a mesh.
  46641. * Internal use
  46642. * @param mesh The mesh to free.
  46643. * @hidden
  46644. */ private _disposeMesh(mesh: Mesh): void;
  46645. /**
  46646. * Gets the class name of the effect layer
  46647. * @returns the string with the class name of the effect layer
  46648. */
  46649. getClassName(): string;
  46650. /**
  46651. * Serializes this glow layer
  46652. * @returns a serialized glow layer object
  46653. */
  46654. serialize(): any;
  46655. /**
  46656. * Creates a Glow Layer from parsed glow layer data
  46657. * @param parsedGlowLayer defines glow layer data
  46658. * @param scene defines the current scene
  46659. * @param rootUrl defines the root URL containing the glow layer information
  46660. * @returns a parsed Glow Layer
  46661. */
  46662. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46663. }
  46664. }
  46665. declare module BABYLON {
  46666. /** @hidden */
  46667. export var glowBlurPostProcessPixelShader: {
  46668. name: string;
  46669. shader: string;
  46670. };
  46671. }
  46672. declare module BABYLON {
  46673. interface AbstractScene {
  46674. /**
  46675. * Return a the first highlight layer of the scene with a given name.
  46676. * @param name The name of the highlight layer to look for.
  46677. * @return The highlight layer if found otherwise null.
  46678. */
  46679. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46680. }
  46681. /**
  46682. * Highlight layer options. This helps customizing the behaviour
  46683. * of the highlight layer.
  46684. */
  46685. export interface IHighlightLayerOptions {
  46686. /**
  46687. * Multiplication factor apply to the canvas size to compute the render target size
  46688. * used to generated the glowing objects (the smaller the faster).
  46689. */
  46690. mainTextureRatio: number;
  46691. /**
  46692. * Enforces a fixed size texture to ensure resize independant blur.
  46693. */
  46694. mainTextureFixedSize?: number;
  46695. /**
  46696. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46697. * of the picture to blur (the smaller the faster).
  46698. */
  46699. blurTextureSizeRatio: number;
  46700. /**
  46701. * How big in texel of the blur texture is the vertical blur.
  46702. */
  46703. blurVerticalSize: number;
  46704. /**
  46705. * How big in texel of the blur texture is the horizontal blur.
  46706. */
  46707. blurHorizontalSize: number;
  46708. /**
  46709. * Alpha blending mode used to apply the blur. Default is combine.
  46710. */
  46711. alphaBlendingMode: number;
  46712. /**
  46713. * The camera attached to the layer.
  46714. */
  46715. camera: Nullable<Camera>;
  46716. /**
  46717. * Should we display highlight as a solid stroke?
  46718. */
  46719. isStroke?: boolean;
  46720. /**
  46721. * The rendering group to draw the layer in.
  46722. */
  46723. renderingGroupId: number;
  46724. }
  46725. /**
  46726. * The highlight layer Helps adding a glow effect around a mesh.
  46727. *
  46728. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46729. * glowy meshes to your scene.
  46730. *
  46731. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46732. */
  46733. export class HighlightLayer extends EffectLayer {
  46734. name: string;
  46735. /**
  46736. * Effect Name of the highlight layer.
  46737. */
  46738. static readonly EffectName: string;
  46739. /**
  46740. * The neutral color used during the preparation of the glow effect.
  46741. * This is black by default as the blend operation is a blend operation.
  46742. */
  46743. static NeutralColor: Color4;
  46744. /**
  46745. * Stencil value used for glowing meshes.
  46746. */
  46747. static GlowingMeshStencilReference: number;
  46748. /**
  46749. * Stencil value used for the other meshes in the scene.
  46750. */
  46751. static NormalMeshStencilReference: number;
  46752. /**
  46753. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46754. */
  46755. innerGlow: boolean;
  46756. /**
  46757. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46758. */
  46759. outerGlow: boolean;
  46760. /**
  46761. * Specifies the horizontal size of the blur.
  46762. */
  46763. /**
  46764. * Gets the horizontal size of the blur.
  46765. */
  46766. blurHorizontalSize: number;
  46767. /**
  46768. * Specifies the vertical size of the blur.
  46769. */
  46770. /**
  46771. * Gets the vertical size of the blur.
  46772. */
  46773. blurVerticalSize: number;
  46774. /**
  46775. * An event triggered when the highlight layer is being blurred.
  46776. */
  46777. onBeforeBlurObservable: Observable<HighlightLayer>;
  46778. /**
  46779. * An event triggered when the highlight layer has been blurred.
  46780. */
  46781. onAfterBlurObservable: Observable<HighlightLayer>;
  46782. private _instanceGlowingMeshStencilReference;
  46783. private _options;
  46784. private _downSamplePostprocess;
  46785. private _horizontalBlurPostprocess;
  46786. private _verticalBlurPostprocess;
  46787. private _blurTexture;
  46788. private _meshes;
  46789. private _excludedMeshes;
  46790. /**
  46791. * Instantiates a new highlight Layer and references it to the scene..
  46792. * @param name The name of the layer
  46793. * @param scene The scene to use the layer in
  46794. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46795. */
  46796. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46797. /**
  46798. * Get the effect name of the layer.
  46799. * @return The effect name
  46800. */
  46801. getEffectName(): string;
  46802. /**
  46803. * Create the merge effect. This is the shader use to blit the information back
  46804. * to the main canvas at the end of the scene rendering.
  46805. */
  46806. protected _createMergeEffect(): Effect;
  46807. /**
  46808. * Creates the render target textures and post processes used in the highlight layer.
  46809. */
  46810. protected _createTextureAndPostProcesses(): void;
  46811. /**
  46812. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46813. */
  46814. needStencil(): boolean;
  46815. /**
  46816. * Checks for the readiness of the element composing the layer.
  46817. * @param subMesh the mesh to check for
  46818. * @param useInstances specify wether or not to use instances to render the mesh
  46819. * @param emissiveTexture the associated emissive texture used to generate the glow
  46820. * @return true if ready otherwise, false
  46821. */
  46822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46823. /**
  46824. * Implementation specific of rendering the generating effect on the main canvas.
  46825. * @param effect The effect used to render through
  46826. */
  46827. protected _internalRender(effect: Effect): void;
  46828. /**
  46829. * Returns true if the layer contains information to display, otherwise false.
  46830. */
  46831. shouldRender(): boolean;
  46832. /**
  46833. * Returns true if the mesh should render, otherwise false.
  46834. * @param mesh The mesh to render
  46835. * @returns true if it should render otherwise false
  46836. */
  46837. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46838. /**
  46839. * Sets the required values for both the emissive texture and and the main color.
  46840. */
  46841. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46842. /**
  46843. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46844. * @param mesh The mesh to exclude from the highlight layer
  46845. */
  46846. addExcludedMesh(mesh: Mesh): void;
  46847. /**
  46848. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46849. * @param mesh The mesh to highlight
  46850. */
  46851. removeExcludedMesh(mesh: Mesh): void;
  46852. /**
  46853. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46854. * @param mesh mesh to test
  46855. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46856. */
  46857. hasMesh(mesh: AbstractMesh): boolean;
  46858. /**
  46859. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46860. * @param mesh The mesh to highlight
  46861. * @param color The color of the highlight
  46862. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46863. */
  46864. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46865. /**
  46866. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46867. * @param mesh The mesh to highlight
  46868. */
  46869. removeMesh(mesh: Mesh): void;
  46870. /**
  46871. * Force the stencil to the normal expected value for none glowing parts
  46872. */
  46873. private _defaultStencilReference;
  46874. /**
  46875. * Free any resources and references associated to a mesh.
  46876. * Internal use
  46877. * @param mesh The mesh to free.
  46878. * @hidden
  46879. */ private _disposeMesh(mesh: Mesh): void;
  46880. /**
  46881. * Dispose the highlight layer and free resources.
  46882. */
  46883. dispose(): void;
  46884. /**
  46885. * Gets the class name of the effect layer
  46886. * @returns the string with the class name of the effect layer
  46887. */
  46888. getClassName(): string;
  46889. /**
  46890. * Serializes this Highlight layer
  46891. * @returns a serialized Highlight layer object
  46892. */
  46893. serialize(): any;
  46894. /**
  46895. * Creates a Highlight layer from parsed Highlight layer data
  46896. * @param parsedHightlightLayer defines the Highlight layer data
  46897. * @param scene defines the current scene
  46898. * @param rootUrl defines the root URL containing the Highlight layer information
  46899. * @returns a parsed Highlight layer
  46900. */
  46901. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46902. }
  46903. }
  46904. declare module BABYLON {
  46905. interface AbstractScene {
  46906. /**
  46907. * The list of layers (background and foreground) of the scene
  46908. */
  46909. layers: Array<Layer>;
  46910. }
  46911. /**
  46912. * Defines the layer scene component responsible to manage any layers
  46913. * in a given scene.
  46914. */
  46915. export class LayerSceneComponent implements ISceneComponent {
  46916. /**
  46917. * The component name helpfull to identify the component in the list of scene components.
  46918. */
  46919. readonly name: string;
  46920. /**
  46921. * The scene the component belongs to.
  46922. */
  46923. scene: Scene;
  46924. private _engine;
  46925. /**
  46926. * Creates a new instance of the component for the given scene
  46927. * @param scene Defines the scene to register the component in
  46928. */
  46929. constructor(scene: Scene);
  46930. /**
  46931. * Registers the component in a given scene
  46932. */
  46933. register(): void;
  46934. /**
  46935. * Rebuilds the elements related to this component in case of
  46936. * context lost for instance.
  46937. */
  46938. rebuild(): void;
  46939. /**
  46940. * Disposes the component and the associated ressources.
  46941. */
  46942. dispose(): void;
  46943. private _draw;
  46944. private _drawCameraPredicate;
  46945. private _drawCameraBackground;
  46946. private _drawCameraForeground;
  46947. private _drawRenderTargetPredicate;
  46948. private _drawRenderTargetBackground;
  46949. private _drawRenderTargetForeground;
  46950. }
  46951. }
  46952. declare module BABYLON {
  46953. /** @hidden */
  46954. export var layerPixelShader: {
  46955. name: string;
  46956. shader: string;
  46957. };
  46958. }
  46959. declare module BABYLON {
  46960. /** @hidden */
  46961. export var layerVertexShader: {
  46962. name: string;
  46963. shader: string;
  46964. };
  46965. }
  46966. declare module BABYLON {
  46967. /**
  46968. * This represents a full screen 2d layer.
  46969. * This can be useful to display a picture in the background of your scene for instance.
  46970. * @see https://www.babylonjs-playground.com/#08A2BS#1
  46971. */
  46972. export class Layer {
  46973. /**
  46974. * Define the name of the layer.
  46975. */
  46976. name: string;
  46977. /**
  46978. * Define the texture the layer should display.
  46979. */
  46980. texture: Nullable<Texture>;
  46981. /**
  46982. * Is the layer in background or foreground.
  46983. */
  46984. isBackground: boolean;
  46985. /**
  46986. * Define the color of the layer (instead of texture).
  46987. */
  46988. color: Color4;
  46989. /**
  46990. * Define the scale of the layer in order to zoom in out of the texture.
  46991. */
  46992. scale: Vector2;
  46993. /**
  46994. * Define an offset for the layer in order to shift the texture.
  46995. */
  46996. offset: Vector2;
  46997. /**
  46998. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  46999. */
  47000. alphaBlendingMode: number;
  47001. /**
  47002. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47003. * Alpha test will not mix with the background color in case of transparency.
  47004. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47005. */
  47006. alphaTest: boolean;
  47007. /**
  47008. * Define a mask to restrict the layer to only some of the scene cameras.
  47009. */
  47010. layerMask: number;
  47011. /**
  47012. * Define the list of render target the layer is visible into.
  47013. */
  47014. renderTargetTextures: RenderTargetTexture[];
  47015. /**
  47016. * Define if the layer is only used in renderTarget or if it also
  47017. * renders in the main frame buffer of the canvas.
  47018. */
  47019. renderOnlyInRenderTargetTextures: boolean;
  47020. private _scene;
  47021. private _vertexBuffers;
  47022. private _indexBuffer;
  47023. private _effect;
  47024. private _alphaTestEffect;
  47025. /**
  47026. * An event triggered when the layer is disposed.
  47027. */
  47028. onDisposeObservable: Observable<Layer>;
  47029. private _onDisposeObserver;
  47030. /**
  47031. * Back compatibility with callback before the onDisposeObservable existed.
  47032. * The set callback will be triggered when the layer has been disposed.
  47033. */
  47034. onDispose: () => void;
  47035. /**
  47036. * An event triggered before rendering the scene
  47037. */
  47038. onBeforeRenderObservable: Observable<Layer>;
  47039. private _onBeforeRenderObserver;
  47040. /**
  47041. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47042. * The set callback will be triggered just before rendering the layer.
  47043. */
  47044. onBeforeRender: () => void;
  47045. /**
  47046. * An event triggered after rendering the scene
  47047. */
  47048. onAfterRenderObservable: Observable<Layer>;
  47049. private _onAfterRenderObserver;
  47050. /**
  47051. * Back compatibility with callback before the onAfterRenderObservable existed.
  47052. * The set callback will be triggered just after rendering the layer.
  47053. */
  47054. onAfterRender: () => void;
  47055. /**
  47056. * Instantiates a new layer.
  47057. * This represents a full screen 2d layer.
  47058. * This can be useful to display a picture in the background of your scene for instance.
  47059. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47060. * @param name Define the name of the layer in the scene
  47061. * @param imgUrl Define the url of the texture to display in the layer
  47062. * @param scene Define the scene the layer belongs to
  47063. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47064. * @param color Defines a color for the layer
  47065. */
  47066. constructor(
  47067. /**
  47068. * Define the name of the layer.
  47069. */
  47070. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47071. private _createIndexBuffer;
  47072. /** @hidden */ private _rebuild(): void;
  47073. /**
  47074. * Renders the layer in the scene.
  47075. */
  47076. render(): void;
  47077. /**
  47078. * Disposes and releases the associated ressources.
  47079. */
  47080. dispose(): void;
  47081. }
  47082. }
  47083. declare module BABYLON {
  47084. /** @hidden */
  47085. export var lensFlarePixelShader: {
  47086. name: string;
  47087. shader: string;
  47088. };
  47089. }
  47090. declare module BABYLON {
  47091. /** @hidden */
  47092. export var lensFlareVertexShader: {
  47093. name: string;
  47094. shader: string;
  47095. };
  47096. }
  47097. declare module BABYLON {
  47098. /**
  47099. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47100. * It is usually composed of several `lensFlare`.
  47101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47102. */
  47103. export class LensFlareSystem {
  47104. /**
  47105. * Define the name of the lens flare system
  47106. */
  47107. name: string;
  47108. /**
  47109. * List of lens flares used in this system.
  47110. */
  47111. lensFlares: LensFlare[];
  47112. /**
  47113. * Define a limit from the border the lens flare can be visible.
  47114. */
  47115. borderLimit: number;
  47116. /**
  47117. * Define a viewport border we do not want to see the lens flare in.
  47118. */
  47119. viewportBorder: number;
  47120. /**
  47121. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47122. */
  47123. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47124. /**
  47125. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47126. */
  47127. layerMask: number;
  47128. /**
  47129. * Define the id of the lens flare system in the scene.
  47130. * (equal to name by default)
  47131. */
  47132. id: string;
  47133. private _scene;
  47134. private _emitter;
  47135. private _vertexBuffers;
  47136. private _indexBuffer;
  47137. private _effect;
  47138. private _positionX;
  47139. private _positionY;
  47140. private _isEnabled;
  47141. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47142. /**
  47143. * Instantiates a lens flare system.
  47144. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47145. * It is usually composed of several `lensFlare`.
  47146. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47147. * @param name Define the name of the lens flare system in the scene
  47148. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47149. * @param scene Define the scene the lens flare system belongs to
  47150. */
  47151. constructor(
  47152. /**
  47153. * Define the name of the lens flare system
  47154. */
  47155. name: string, emitter: any, scene: Scene);
  47156. /**
  47157. * Define if the lens flare system is enabled.
  47158. */
  47159. isEnabled: boolean;
  47160. /**
  47161. * Get the scene the effects belongs to.
  47162. * @returns the scene holding the lens flare system
  47163. */
  47164. getScene(): Scene;
  47165. /**
  47166. * Get the emitter of the lens flare system.
  47167. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47168. * @returns the emitter of the lens flare system
  47169. */
  47170. getEmitter(): any;
  47171. /**
  47172. * Set the emitter of the lens flare system.
  47173. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47174. * @param newEmitter Define the new emitter of the system
  47175. */
  47176. setEmitter(newEmitter: any): void;
  47177. /**
  47178. * Get the lens flare system emitter position.
  47179. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47180. * @returns the position
  47181. */
  47182. getEmitterPosition(): Vector3;
  47183. /**
  47184. * @hidden
  47185. */
  47186. computeEffectivePosition(globalViewport: Viewport): boolean;
  47187. /** @hidden */ private _isVisible(): boolean;
  47188. /**
  47189. * @hidden
  47190. */
  47191. render(): boolean;
  47192. /**
  47193. * Dispose and release the lens flare with its associated resources.
  47194. */
  47195. dispose(): void;
  47196. /**
  47197. * Parse a lens flare system from a JSON repressentation
  47198. * @param parsedLensFlareSystem Define the JSON to parse
  47199. * @param scene Define the scene the parsed system should be instantiated in
  47200. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47201. * @returns the parsed system
  47202. */
  47203. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47204. /**
  47205. * Serialize the current Lens Flare System into a JSON representation.
  47206. * @returns the serialized JSON
  47207. */
  47208. serialize(): any;
  47209. }
  47210. }
  47211. declare module BABYLON {
  47212. /**
  47213. * This represents one of the lens effect in a `lensFlareSystem`.
  47214. * It controls one of the indiviual texture used in the effect.
  47215. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47216. */
  47217. export class LensFlare {
  47218. /**
  47219. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47220. */
  47221. size: number;
  47222. /**
  47223. * 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.
  47224. */
  47225. position: number;
  47226. /**
  47227. * Define the lens color.
  47228. */
  47229. color: Color3;
  47230. /**
  47231. * Define the lens texture.
  47232. */
  47233. texture: Nullable<Texture>;
  47234. /**
  47235. * Define the alpha mode to render this particular lens.
  47236. */
  47237. alphaMode: number;
  47238. private _system;
  47239. /**
  47240. * Creates a new Lens Flare.
  47241. * This represents one of the lens effect in a `lensFlareSystem`.
  47242. * It controls one of the indiviual texture used in the effect.
  47243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47244. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47245. * @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.
  47246. * @param color Define the lens color
  47247. * @param imgUrl Define the lens texture url
  47248. * @param system Define the `lensFlareSystem` this flare is part of
  47249. * @returns The newly created Lens Flare
  47250. */
  47251. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47252. /**
  47253. * Instantiates a new Lens Flare.
  47254. * This represents one of the lens effect in a `lensFlareSystem`.
  47255. * It controls one of the indiviual texture used in the effect.
  47256. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47257. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47258. * @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.
  47259. * @param color Define the lens color
  47260. * @param imgUrl Define the lens texture url
  47261. * @param system Define the `lensFlareSystem` this flare is part of
  47262. */
  47263. constructor(
  47264. /**
  47265. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47266. */
  47267. size: number,
  47268. /**
  47269. * 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.
  47270. */
  47271. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47272. /**
  47273. * Dispose and release the lens flare with its associated resources.
  47274. */
  47275. dispose(): void;
  47276. }
  47277. }
  47278. declare module BABYLON {
  47279. interface AbstractScene {
  47280. /**
  47281. * The list of lens flare system added to the scene
  47282. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47283. */
  47284. lensFlareSystems: Array<LensFlareSystem>;
  47285. /**
  47286. * Removes the given lens flare system from this scene.
  47287. * @param toRemove The lens flare system to remove
  47288. * @returns The index of the removed lens flare system
  47289. */
  47290. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47291. /**
  47292. * Adds the given lens flare system to this scene
  47293. * @param newLensFlareSystem The lens flare system to add
  47294. */
  47295. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47296. /**
  47297. * Gets a lens flare system using its name
  47298. * @param name defines the name to look for
  47299. * @returns the lens flare system or null if not found
  47300. */
  47301. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47302. /**
  47303. * Gets a lens flare system using its id
  47304. * @param id defines the id to look for
  47305. * @returns the lens flare system or null if not found
  47306. */
  47307. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47308. }
  47309. /**
  47310. * Defines the lens flare scene component responsible to manage any lens flares
  47311. * in a given scene.
  47312. */
  47313. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47314. /**
  47315. * The component name helpfull to identify the component in the list of scene components.
  47316. */
  47317. readonly name: string;
  47318. /**
  47319. * The scene the component belongs to.
  47320. */
  47321. scene: Scene;
  47322. /**
  47323. * Creates a new instance of the component for the given scene
  47324. * @param scene Defines the scene to register the component in
  47325. */
  47326. constructor(scene: Scene);
  47327. /**
  47328. * Registers the component in a given scene
  47329. */
  47330. register(): void;
  47331. /**
  47332. * Rebuilds the elements related to this component in case of
  47333. * context lost for instance.
  47334. */
  47335. rebuild(): void;
  47336. /**
  47337. * Adds all the element from the container to the scene
  47338. * @param container the container holding the elements
  47339. */
  47340. addFromContainer(container: AbstractScene): void;
  47341. /**
  47342. * Removes all the elements in the container from the scene
  47343. * @param container contains the elements to remove
  47344. * @param dispose if the removed element should be disposed (default: false)
  47345. */
  47346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47347. /**
  47348. * Serializes the component data to the specified json object
  47349. * @param serializationObject The object to serialize to
  47350. */
  47351. serialize(serializationObject: any): void;
  47352. /**
  47353. * Disposes the component and the associated ressources.
  47354. */
  47355. dispose(): void;
  47356. private _draw;
  47357. }
  47358. }
  47359. declare module BABYLON {
  47360. /**
  47361. * Defines the shadow generator component responsible to manage any shadow generators
  47362. * in a given scene.
  47363. */
  47364. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47365. /**
  47366. * The component name helpfull to identify the component in the list of scene components.
  47367. */
  47368. readonly name: string;
  47369. /**
  47370. * The scene the component belongs to.
  47371. */
  47372. scene: Scene;
  47373. /**
  47374. * Creates a new instance of the component for the given scene
  47375. * @param scene Defines the scene to register the component in
  47376. */
  47377. constructor(scene: Scene);
  47378. /**
  47379. * Registers the component in a given scene
  47380. */
  47381. register(): void;
  47382. /**
  47383. * Rebuilds the elements related to this component in case of
  47384. * context lost for instance.
  47385. */
  47386. rebuild(): void;
  47387. /**
  47388. * Serializes the component data to the specified json object
  47389. * @param serializationObject The object to serialize to
  47390. */
  47391. serialize(serializationObject: any): void;
  47392. /**
  47393. * Adds all the element from the container to the scene
  47394. * @param container the container holding the elements
  47395. */
  47396. addFromContainer(container: AbstractScene): void;
  47397. /**
  47398. * Removes all the elements in the container from the scene
  47399. * @param container contains the elements to remove
  47400. * @param dispose if the removed element should be disposed (default: false)
  47401. */
  47402. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47403. /**
  47404. * Rebuilds the elements related to this component in case of
  47405. * context lost for instance.
  47406. */
  47407. dispose(): void;
  47408. private _gatherRenderTargets;
  47409. }
  47410. }
  47411. declare module BABYLON {
  47412. /**
  47413. * A point light is a light defined by an unique point in world space.
  47414. * The light is emitted in every direction from this point.
  47415. * A good example of a point light is a standard light bulb.
  47416. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47417. */
  47418. export class PointLight extends ShadowLight {
  47419. private _shadowAngle;
  47420. /**
  47421. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47422. * This specifies what angle the shadow will use to be created.
  47423. *
  47424. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47425. */
  47426. /**
  47427. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47428. * This specifies what angle the shadow will use to be created.
  47429. *
  47430. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47431. */
  47432. shadowAngle: number;
  47433. /**
  47434. * Gets the direction if it has been set.
  47435. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47436. */
  47437. /**
  47438. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47439. */
  47440. direction: Vector3;
  47441. /**
  47442. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47443. * A PointLight emits the light in every direction.
  47444. * It can cast shadows.
  47445. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47446. * ```javascript
  47447. * var pointLight = new PointLight("pl", camera.position, scene);
  47448. * ```
  47449. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47450. * @param name The light friendly name
  47451. * @param position The position of the point light in the scene
  47452. * @param scene The scene the lights belongs to
  47453. */
  47454. constructor(name: string, position: Vector3, scene: Scene);
  47455. /**
  47456. * Returns the string "PointLight"
  47457. * @returns the class name
  47458. */
  47459. getClassName(): string;
  47460. /**
  47461. * Returns the integer 0.
  47462. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47463. */
  47464. getTypeID(): number;
  47465. /**
  47466. * Specifies wether or not the shadowmap should be a cube texture.
  47467. * @returns true if the shadowmap needs to be a cube texture.
  47468. */
  47469. needCube(): boolean;
  47470. /**
  47471. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47472. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47473. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47474. */
  47475. getShadowDirection(faceIndex?: number): Vector3;
  47476. /**
  47477. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47478. * - fov = PI / 2
  47479. * - aspect ratio : 1.0
  47480. * - z-near and far equal to the active camera minZ and maxZ.
  47481. * Returns the PointLight.
  47482. */
  47483. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47484. protected _buildUniformLayout(): void;
  47485. /**
  47486. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47487. * @param effect The effect to update
  47488. * @param lightIndex The index of the light in the effect to update
  47489. * @returns The point light
  47490. */
  47491. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47492. /**
  47493. * Prepares the list of defines specific to the light type.
  47494. * @param defines the list of defines
  47495. * @param lightIndex defines the index of the light for the effect
  47496. */
  47497. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47498. }
  47499. }
  47500. declare module BABYLON {
  47501. /**
  47502. * Header information of HDR texture files.
  47503. */
  47504. export interface HDRInfo {
  47505. /**
  47506. * The height of the texture in pixels.
  47507. */
  47508. height: number;
  47509. /**
  47510. * The width of the texture in pixels.
  47511. */
  47512. width: number;
  47513. /**
  47514. * The index of the beginning of the data in the binary file.
  47515. */
  47516. dataPosition: number;
  47517. }
  47518. /**
  47519. * This groups tools to convert HDR texture to native colors array.
  47520. */
  47521. export class HDRTools {
  47522. private static Ldexp;
  47523. private static Rgbe2float;
  47524. private static readStringLine;
  47525. /**
  47526. * Reads header information from an RGBE texture stored in a native array.
  47527. * More information on this format are available here:
  47528. * https://en.wikipedia.org/wiki/RGBE_image_format
  47529. *
  47530. * @param uint8array The binary file stored in native array.
  47531. * @return The header information.
  47532. */
  47533. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47534. /**
  47535. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47536. * This RGBE texture needs to store the information as a panorama.
  47537. *
  47538. * More information on this format are available here:
  47539. * https://en.wikipedia.org/wiki/RGBE_image_format
  47540. *
  47541. * @param buffer The binary file stored in an array buffer.
  47542. * @param size The expected size of the extracted cubemap.
  47543. * @return The Cube Map information.
  47544. */
  47545. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47546. /**
  47547. * Returns the pixels data extracted from an RGBE texture.
  47548. * This pixels will be stored left to right up to down in the R G B order in one array.
  47549. *
  47550. * More information on this format are available here:
  47551. * https://en.wikipedia.org/wiki/RGBE_image_format
  47552. *
  47553. * @param uint8array The binary file stored in an array buffer.
  47554. * @param hdrInfo The header information of the file.
  47555. * @return The pixels data in RGB right to left up to down order.
  47556. */
  47557. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47558. private static RGBE_ReadPixels_RLE;
  47559. }
  47560. }
  47561. declare module BABYLON {
  47562. /**
  47563. * This represents a texture coming from an HDR input.
  47564. *
  47565. * The only supported format is currently panorama picture stored in RGBE format.
  47566. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47567. */
  47568. export class HDRCubeTexture extends BaseTexture {
  47569. private static _facesMapping;
  47570. private _generateHarmonics;
  47571. private _noMipmap;
  47572. private _textureMatrix;
  47573. private _size;
  47574. private _onLoad;
  47575. private _onError;
  47576. /**
  47577. * The texture URL.
  47578. */
  47579. url: string;
  47580. /**
  47581. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47582. */
  47583. coordinatesMode: number;
  47584. protected _isBlocking: boolean;
  47585. /**
  47586. * Sets wether or not the texture is blocking during loading.
  47587. */
  47588. /**
  47589. * Gets wether or not the texture is blocking during loading.
  47590. */
  47591. isBlocking: boolean;
  47592. protected _rotationY: number;
  47593. /**
  47594. * Sets texture matrix rotation angle around Y axis in radians.
  47595. */
  47596. /**
  47597. * Gets texture matrix rotation angle around Y axis radians.
  47598. */
  47599. rotationY: number;
  47600. /**
  47601. * Gets or sets the center of the bounding box associated with the cube texture
  47602. * It must define where the camera used to render the texture was set
  47603. */
  47604. boundingBoxPosition: Vector3;
  47605. private _boundingBoxSize;
  47606. /**
  47607. * Gets or sets the size of the bounding box associated with the cube texture
  47608. * When defined, the cubemap will switch to local mode
  47609. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47610. * @example https://www.babylonjs-playground.com/#RNASML
  47611. */
  47612. boundingBoxSize: Vector3;
  47613. /**
  47614. * Instantiates an HDRTexture from the following parameters.
  47615. *
  47616. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47617. * @param scene The scene the texture will be used in
  47618. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47619. * @param noMipmap Forces to not generate the mipmap if true
  47620. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47621. * @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)
  47622. * @param reserved Reserved flag for internal use.
  47623. */
  47624. 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>);
  47625. /**
  47626. * Get the current class name of the texture useful for serialization or dynamic coding.
  47627. * @returns "HDRCubeTexture"
  47628. */
  47629. getClassName(): string;
  47630. /**
  47631. * Occurs when the file is raw .hdr file.
  47632. */
  47633. private loadTexture;
  47634. clone(): HDRCubeTexture;
  47635. delayLoad(): void;
  47636. /**
  47637. * Get the texture reflection matrix used to rotate/transform the reflection.
  47638. * @returns the reflection matrix
  47639. */
  47640. getReflectionTextureMatrix(): Matrix;
  47641. /**
  47642. * Set the texture reflection matrix used to rotate/transform the reflection.
  47643. * @param value Define the reflection matrix to set
  47644. */
  47645. setReflectionTextureMatrix(value: Matrix): void;
  47646. /**
  47647. * Parses a JSON representation of an HDR Texture in order to create the texture
  47648. * @param parsedTexture Define the JSON representation
  47649. * @param scene Define the scene the texture should be created in
  47650. * @param rootUrl Define the root url in case we need to load relative dependencies
  47651. * @returns the newly created texture after parsing
  47652. */
  47653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47654. serialize(): any;
  47655. }
  47656. }
  47657. declare module BABYLON {
  47658. /**
  47659. * Class used to control physics engine
  47660. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47661. */
  47662. export class PhysicsEngine implements IPhysicsEngine {
  47663. private _physicsPlugin;
  47664. /**
  47665. * Global value used to control the smallest number supported by the simulation
  47666. */
  47667. static Epsilon: number;
  47668. private _impostors;
  47669. private _joints;
  47670. /**
  47671. * Gets the gravity vector used by the simulation
  47672. */
  47673. gravity: Vector3;
  47674. /**
  47675. * Factory used to create the default physics plugin.
  47676. * @returns The default physics plugin
  47677. */
  47678. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47679. /**
  47680. * Creates a new Physics Engine
  47681. * @param gravity defines the gravity vector used by the simulation
  47682. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47683. */
  47684. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47685. /**
  47686. * Sets the gravity vector used by the simulation
  47687. * @param gravity defines the gravity vector to use
  47688. */
  47689. setGravity(gravity: Vector3): void;
  47690. /**
  47691. * Set the time step of the physics engine.
  47692. * Default is 1/60.
  47693. * To slow it down, enter 1/600 for example.
  47694. * To speed it up, 1/30
  47695. * @param newTimeStep defines the new timestep to apply to this world.
  47696. */
  47697. setTimeStep(newTimeStep?: number): void;
  47698. /**
  47699. * Get the time step of the physics engine.
  47700. * @returns the current time step
  47701. */
  47702. getTimeStep(): number;
  47703. /**
  47704. * Release all resources
  47705. */
  47706. dispose(): void;
  47707. /**
  47708. * Gets the name of the current physics plugin
  47709. * @returns the name of the plugin
  47710. */
  47711. getPhysicsPluginName(): string;
  47712. /**
  47713. * Adding a new impostor for the impostor tracking.
  47714. * This will be done by the impostor itself.
  47715. * @param impostor the impostor to add
  47716. */
  47717. addImpostor(impostor: PhysicsImpostor): void;
  47718. /**
  47719. * Remove an impostor from the engine.
  47720. * This impostor and its mesh will not longer be updated by the physics engine.
  47721. * @param impostor the impostor to remove
  47722. */
  47723. removeImpostor(impostor: PhysicsImpostor): void;
  47724. /**
  47725. * Add a joint to the physics engine
  47726. * @param mainImpostor defines the main impostor to which the joint is added.
  47727. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47728. * @param joint defines the joint that will connect both impostors.
  47729. */
  47730. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47731. /**
  47732. * Removes a joint from the simulation
  47733. * @param mainImpostor defines the impostor used with the joint
  47734. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47735. * @param joint defines the joint to remove
  47736. */
  47737. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47738. /**
  47739. * Called by the scene. No need to call it.
  47740. * @param delta defines the timespam between frames
  47741. */ private _step(delta: number): void;
  47742. /**
  47743. * Gets the current plugin used to run the simulation
  47744. * @returns current plugin
  47745. */
  47746. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47747. /**
  47748. * Gets the list of physic impostors
  47749. * @returns an array of PhysicsImpostor
  47750. */
  47751. getImpostors(): Array<PhysicsImpostor>;
  47752. /**
  47753. * Gets the impostor for a physics enabled object
  47754. * @param object defines the object impersonated by the impostor
  47755. * @returns the PhysicsImpostor or null if not found
  47756. */
  47757. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47758. /**
  47759. * Gets the impostor for a physics body object
  47760. * @param body defines physics body used by the impostor
  47761. * @returns the PhysicsImpostor or null if not found
  47762. */
  47763. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47764. /**
  47765. * Does a raycast in the physics world
  47766. * @param from when should the ray start?
  47767. * @param to when should the ray end?
  47768. * @returns PhysicsRaycastResult
  47769. */
  47770. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47771. }
  47772. }
  47773. declare module BABYLON {
  47774. /** @hidden */
  47775. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47776. private _useDeltaForWorldStep;
  47777. world: any;
  47778. name: string;
  47779. private _physicsMaterials;
  47780. private _fixedTimeStep;
  47781. private _cannonRaycastResult;
  47782. private _raycastResult;
  47783. private _removeAfterStep;
  47784. BJSCANNON: any;
  47785. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47786. setGravity(gravity: Vector3): void;
  47787. setTimeStep(timeStep: number): void;
  47788. getTimeStep(): number;
  47789. executeStep(delta: number): void;
  47790. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47791. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47792. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47793. private _processChildMeshes;
  47794. removePhysicsBody(impostor: PhysicsImpostor): void;
  47795. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47796. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47797. private _addMaterial;
  47798. private _checkWithEpsilon;
  47799. private _createShape;
  47800. private _createHeightmap;
  47801. private _minus90X;
  47802. private _plus90X;
  47803. private _tmpPosition;
  47804. private _tmpDeltaPosition;
  47805. private _tmpUnityRotation;
  47806. private _updatePhysicsBodyTransformation;
  47807. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47808. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47809. isSupported(): boolean;
  47810. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47811. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47812. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47813. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47814. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47815. getBodyMass(impostor: PhysicsImpostor): number;
  47816. getBodyFriction(impostor: PhysicsImpostor): number;
  47817. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47818. getBodyRestitution(impostor: PhysicsImpostor): number;
  47819. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47820. sleepBody(impostor: PhysicsImpostor): void;
  47821. wakeUpBody(impostor: PhysicsImpostor): void;
  47822. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47823. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47824. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47825. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47826. getRadius(impostor: PhysicsImpostor): number;
  47827. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47828. dispose(): void;
  47829. private _extendNamespace;
  47830. /**
  47831. * Does a raycast in the physics world
  47832. * @param from when should the ray start?
  47833. * @param to when should the ray end?
  47834. * @returns PhysicsRaycastResult
  47835. */
  47836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47837. }
  47838. }
  47839. declare module BABYLON {
  47840. /** @hidden */
  47841. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47842. world: any;
  47843. name: string;
  47844. BJSOIMO: any;
  47845. private _raycastResult;
  47846. constructor(iterations?: number, oimoInjection?: any);
  47847. setGravity(gravity: Vector3): void;
  47848. setTimeStep(timeStep: number): void;
  47849. getTimeStep(): number;
  47850. private _tmpImpostorsArray;
  47851. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47852. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47853. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47854. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47855. private _tmpPositionVector;
  47856. removePhysicsBody(impostor: PhysicsImpostor): void;
  47857. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47858. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47859. isSupported(): boolean;
  47860. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47861. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47862. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47863. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47864. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47865. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47866. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47867. getBodyMass(impostor: PhysicsImpostor): number;
  47868. getBodyFriction(impostor: PhysicsImpostor): number;
  47869. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47870. getBodyRestitution(impostor: PhysicsImpostor): number;
  47871. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47872. sleepBody(impostor: PhysicsImpostor): void;
  47873. wakeUpBody(impostor: PhysicsImpostor): void;
  47874. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47875. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47876. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47877. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47878. getRadius(impostor: PhysicsImpostor): number;
  47879. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47880. dispose(): void;
  47881. /**
  47882. * Does a raycast in the physics world
  47883. * @param from when should the ray start?
  47884. * @param to when should the ray end?
  47885. * @returns PhysicsRaycastResult
  47886. */
  47887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47888. }
  47889. }
  47890. declare module BABYLON {
  47891. /**
  47892. * Class containing static functions to help procedurally build meshes
  47893. */
  47894. export class RibbonBuilder {
  47895. /**
  47896. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47897. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47898. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47899. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47900. * * 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
  47901. * * 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
  47902. * * 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
  47903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47904. * * 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
  47905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47906. * * 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
  47907. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47908. * * 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
  47909. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47911. * @param name defines the name of the mesh
  47912. * @param options defines the options used to create the mesh
  47913. * @param scene defines the hosting scene
  47914. * @returns the ribbon mesh
  47915. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47916. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47917. */
  47918. static CreateRibbon(name: string, options: {
  47919. pathArray: Vector3[][];
  47920. closeArray?: boolean;
  47921. closePath?: boolean;
  47922. offset?: number;
  47923. updatable?: boolean;
  47924. sideOrientation?: number;
  47925. frontUVs?: Vector4;
  47926. backUVs?: Vector4;
  47927. instance?: Mesh;
  47928. invertUV?: boolean;
  47929. uvs?: Vector2[];
  47930. colors?: Color4[];
  47931. }, scene?: Nullable<Scene>): Mesh;
  47932. }
  47933. }
  47934. declare module BABYLON {
  47935. /**
  47936. * Class containing static functions to help procedurally build meshes
  47937. */
  47938. export class ShapeBuilder {
  47939. /**
  47940. * 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.
  47941. * * 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.
  47942. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47943. * * 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.
  47944. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47945. * * 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
  47946. * * 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
  47947. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47949. * * 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
  47950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47952. * @param name defines the name of the mesh
  47953. * @param options defines the options used to create the mesh
  47954. * @param scene defines the hosting scene
  47955. * @returns the extruded shape mesh
  47956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47958. */
  47959. static ExtrudeShape(name: string, options: {
  47960. shape: Vector3[];
  47961. path: Vector3[];
  47962. scale?: number;
  47963. rotation?: number;
  47964. cap?: number;
  47965. updatable?: boolean;
  47966. sideOrientation?: number;
  47967. frontUVs?: Vector4;
  47968. backUVs?: Vector4;
  47969. instance?: Mesh;
  47970. invertUV?: boolean;
  47971. }, scene?: Nullable<Scene>): Mesh;
  47972. /**
  47973. * Creates an custom extruded shape mesh.
  47974. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47975. * * 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.
  47976. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47977. * * 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
  47978. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47979. * * 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
  47980. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47981. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47982. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47983. * * 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
  47984. * * 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
  47985. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47987. * * 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
  47988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47990. * @param name defines the name of the mesh
  47991. * @param options defines the options used to create the mesh
  47992. * @param scene defines the hosting scene
  47993. * @returns the custom extruded shape mesh
  47994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47995. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47997. */
  47998. static ExtrudeShapeCustom(name: string, options: {
  47999. shape: Vector3[];
  48000. path: Vector3[];
  48001. scaleFunction?: any;
  48002. rotationFunction?: any;
  48003. ribbonCloseArray?: boolean;
  48004. ribbonClosePath?: boolean;
  48005. cap?: number;
  48006. updatable?: boolean;
  48007. sideOrientation?: number;
  48008. frontUVs?: Vector4;
  48009. backUVs?: Vector4;
  48010. instance?: Mesh;
  48011. invertUV?: boolean;
  48012. }, scene?: Nullable<Scene>): Mesh;
  48013. private static _ExtrudeShapeGeneric;
  48014. }
  48015. }
  48016. declare module BABYLON {
  48017. /**
  48018. * AmmoJS Physics plugin
  48019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48020. * @see https://github.com/kripken/ammo.js/
  48021. */
  48022. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48023. private _useDeltaForWorldStep;
  48024. /**
  48025. * Reference to the Ammo library
  48026. */
  48027. bjsAMMO: any;
  48028. /**
  48029. * Created ammoJS world which physics bodies are added to
  48030. */
  48031. world: any;
  48032. /**
  48033. * Name of the plugin
  48034. */
  48035. name: string;
  48036. private _timeStep;
  48037. private _fixedTimeStep;
  48038. private _maxSteps;
  48039. private _tmpQuaternion;
  48040. private _tmpAmmoTransform;
  48041. private _tmpAmmoQuaternion;
  48042. private _tmpAmmoConcreteContactResultCallback;
  48043. private _collisionConfiguration;
  48044. private _dispatcher;
  48045. private _overlappingPairCache;
  48046. private _solver;
  48047. private _softBodySolver;
  48048. private _tmpAmmoVectorA;
  48049. private _tmpAmmoVectorB;
  48050. private _tmpAmmoVectorC;
  48051. private _tmpAmmoVectorD;
  48052. private _tmpContactCallbackResult;
  48053. private _tmpAmmoVectorRCA;
  48054. private _tmpAmmoVectorRCB;
  48055. private _raycastResult;
  48056. private static readonly DISABLE_COLLISION_FLAG;
  48057. private static readonly KINEMATIC_FLAG;
  48058. private static readonly DISABLE_DEACTIVATION_FLAG;
  48059. /**
  48060. * Initializes the ammoJS plugin
  48061. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48062. * @param ammoInjection can be used to inject your own ammo reference
  48063. */
  48064. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48065. /**
  48066. * Sets the gravity of the physics world (m/(s^2))
  48067. * @param gravity Gravity to set
  48068. */
  48069. setGravity(gravity: Vector3): void;
  48070. /**
  48071. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48072. * @param timeStep timestep to use in seconds
  48073. */
  48074. setTimeStep(timeStep: number): void;
  48075. /**
  48076. * 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)
  48077. * @param fixedTimeStep fixedTimeStep to use in seconds
  48078. */
  48079. setFixedTimeStep(fixedTimeStep: number): void;
  48080. /**
  48081. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48082. * @param maxSteps the maximum number of steps by the physics engine per frame
  48083. */
  48084. setMaxSteps(maxSteps: number): void;
  48085. /**
  48086. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48087. * @returns the current timestep in seconds
  48088. */
  48089. getTimeStep(): number;
  48090. private _isImpostorInContact;
  48091. private _isImpostorPairInContact;
  48092. private _stepSimulation;
  48093. /**
  48094. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48095. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48096. * After the step the babylon meshes are set to the position of the physics imposters
  48097. * @param delta amount of time to step forward
  48098. * @param impostors array of imposters to update before/after the step
  48099. */
  48100. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48101. /**
  48102. * Update babylon mesh to match physics world object
  48103. * @param impostor imposter to match
  48104. */
  48105. private _afterSoftStep;
  48106. /**
  48107. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48108. * @param impostor imposter to match
  48109. */
  48110. private _ropeStep;
  48111. /**
  48112. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48113. * @param impostor imposter to match
  48114. */
  48115. private _softbodyOrClothStep;
  48116. private _tmpVector;
  48117. private _tmpMatrix;
  48118. /**
  48119. * Applies an impulse on the imposter
  48120. * @param impostor imposter to apply impulse to
  48121. * @param force amount of force to be applied to the imposter
  48122. * @param contactPoint the location to apply the impulse on the imposter
  48123. */
  48124. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48125. /**
  48126. * Applies a force on the imposter
  48127. * @param impostor imposter to apply force
  48128. * @param force amount of force to be applied to the imposter
  48129. * @param contactPoint the location to apply the force on the imposter
  48130. */
  48131. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48132. /**
  48133. * Creates a physics body using the plugin
  48134. * @param impostor the imposter to create the physics body on
  48135. */
  48136. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48137. /**
  48138. * Removes the physics body from the imposter and disposes of the body's memory
  48139. * @param impostor imposter to remove the physics body from
  48140. */
  48141. removePhysicsBody(impostor: PhysicsImpostor): void;
  48142. /**
  48143. * Generates a joint
  48144. * @param impostorJoint the imposter joint to create the joint with
  48145. */
  48146. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48147. /**
  48148. * Removes a joint
  48149. * @param impostorJoint the imposter joint to remove the joint from
  48150. */
  48151. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48152. private _addMeshVerts;
  48153. /**
  48154. * Initialise the soft body vertices to match its object's (mesh) vertices
  48155. * Softbody vertices (nodes) are in world space and to match this
  48156. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48157. * @param impostor to create the softbody for
  48158. */
  48159. private _softVertexData;
  48160. /**
  48161. * Create an impostor's soft body
  48162. * @param impostor to create the softbody for
  48163. */
  48164. private _createSoftbody;
  48165. /**
  48166. * Create cloth for an impostor
  48167. * @param impostor to create the softbody for
  48168. */
  48169. private _createCloth;
  48170. /**
  48171. * Create rope for an impostor
  48172. * @param impostor to create the softbody for
  48173. */
  48174. private _createRope;
  48175. private _addHullVerts;
  48176. private _createShape;
  48177. /**
  48178. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48179. * @param impostor imposter containing the physics body and babylon object
  48180. */
  48181. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48182. /**
  48183. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48184. * @param impostor imposter containing the physics body and babylon object
  48185. * @param newPosition new position
  48186. * @param newRotation new rotation
  48187. */
  48188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48189. /**
  48190. * If this plugin is supported
  48191. * @returns true if its supported
  48192. */
  48193. isSupported(): boolean;
  48194. /**
  48195. * Sets the linear velocity of the physics body
  48196. * @param impostor imposter to set the velocity on
  48197. * @param velocity velocity to set
  48198. */
  48199. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48200. /**
  48201. * Sets the angular velocity of the physics body
  48202. * @param impostor imposter to set the velocity on
  48203. * @param velocity velocity to set
  48204. */
  48205. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48206. /**
  48207. * gets the linear velocity
  48208. * @param impostor imposter to get linear velocity from
  48209. * @returns linear velocity
  48210. */
  48211. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48212. /**
  48213. * gets the angular velocity
  48214. * @param impostor imposter to get angular velocity from
  48215. * @returns angular velocity
  48216. */
  48217. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48218. /**
  48219. * Sets the mass of physics body
  48220. * @param impostor imposter to set the mass on
  48221. * @param mass mass to set
  48222. */
  48223. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48224. /**
  48225. * Gets the mass of the physics body
  48226. * @param impostor imposter to get the mass from
  48227. * @returns mass
  48228. */
  48229. getBodyMass(impostor: PhysicsImpostor): number;
  48230. /**
  48231. * Gets friction of the impostor
  48232. * @param impostor impostor to get friction from
  48233. * @returns friction value
  48234. */
  48235. getBodyFriction(impostor: PhysicsImpostor): number;
  48236. /**
  48237. * Sets friction of the impostor
  48238. * @param impostor impostor to set friction on
  48239. * @param friction friction value
  48240. */
  48241. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48242. /**
  48243. * Gets restitution of the impostor
  48244. * @param impostor impostor to get restitution from
  48245. * @returns restitution value
  48246. */
  48247. getBodyRestitution(impostor: PhysicsImpostor): number;
  48248. /**
  48249. * Sets resitution of the impostor
  48250. * @param impostor impostor to set resitution on
  48251. * @param restitution resitution value
  48252. */
  48253. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48254. /**
  48255. * Gets pressure inside the impostor
  48256. * @param impostor impostor to get pressure from
  48257. * @returns pressure value
  48258. */
  48259. getBodyPressure(impostor: PhysicsImpostor): number;
  48260. /**
  48261. * Sets pressure inside a soft body impostor
  48262. * Cloth and rope must remain 0 pressure
  48263. * @param impostor impostor to set pressure on
  48264. * @param pressure pressure value
  48265. */
  48266. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48267. /**
  48268. * Gets stiffness of the impostor
  48269. * @param impostor impostor to get stiffness from
  48270. * @returns pressure value
  48271. */
  48272. getBodyStiffness(impostor: PhysicsImpostor): number;
  48273. /**
  48274. * Sets stiffness of the impostor
  48275. * @param impostor impostor to set stiffness on
  48276. * @param stiffness stiffness value from 0 to 1
  48277. */
  48278. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48279. /**
  48280. * Gets velocityIterations of the impostor
  48281. * @param impostor impostor to get velocity iterations from
  48282. * @returns velocityIterations value
  48283. */
  48284. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48285. /**
  48286. * Sets velocityIterations of the impostor
  48287. * @param impostor impostor to set velocity iterations on
  48288. * @param velocityIterations velocityIterations value
  48289. */
  48290. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48291. /**
  48292. * Gets positionIterations of the impostor
  48293. * @param impostor impostor to get position iterations from
  48294. * @returns positionIterations value
  48295. */
  48296. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48297. /**
  48298. * Sets positionIterations of the impostor
  48299. * @param impostor impostor to set position on
  48300. * @param positionIterations positionIterations value
  48301. */
  48302. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48303. /**
  48304. * Append an anchor to a cloth object
  48305. * @param impostor is the cloth impostor to add anchor to
  48306. * @param otherImpostor is the rigid impostor to anchor to
  48307. * @param width ratio across width from 0 to 1
  48308. * @param height ratio up height from 0 to 1
  48309. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48310. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48311. */
  48312. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48313. /**
  48314. * Append an hook to a rope object
  48315. * @param impostor is the rope impostor to add hook to
  48316. * @param otherImpostor is the rigid impostor to hook to
  48317. * @param length ratio along the rope from 0 to 1
  48318. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48319. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48320. */
  48321. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48322. /**
  48323. * Sleeps the physics body and stops it from being active
  48324. * @param impostor impostor to sleep
  48325. */
  48326. sleepBody(impostor: PhysicsImpostor): void;
  48327. /**
  48328. * Activates the physics body
  48329. * @param impostor impostor to activate
  48330. */
  48331. wakeUpBody(impostor: PhysicsImpostor): void;
  48332. /**
  48333. * Updates the distance parameters of the joint
  48334. * @param joint joint to update
  48335. * @param maxDistance maximum distance of the joint
  48336. * @param minDistance minimum distance of the joint
  48337. */
  48338. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48339. /**
  48340. * Sets a motor on the joint
  48341. * @param joint joint to set motor on
  48342. * @param speed speed of the motor
  48343. * @param maxForce maximum force of the motor
  48344. * @param motorIndex index of the motor
  48345. */
  48346. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48347. /**
  48348. * Sets the motors limit
  48349. * @param joint joint to set limit on
  48350. * @param upperLimit upper limit
  48351. * @param lowerLimit lower limit
  48352. */
  48353. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48354. /**
  48355. * Syncs the position and rotation of a mesh with the impostor
  48356. * @param mesh mesh to sync
  48357. * @param impostor impostor to update the mesh with
  48358. */
  48359. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48360. /**
  48361. * Gets the radius of the impostor
  48362. * @param impostor impostor to get radius from
  48363. * @returns the radius
  48364. */
  48365. getRadius(impostor: PhysicsImpostor): number;
  48366. /**
  48367. * Gets the box size of the impostor
  48368. * @param impostor impostor to get box size from
  48369. * @param result the resulting box size
  48370. */
  48371. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48372. /**
  48373. * Disposes of the impostor
  48374. */
  48375. dispose(): void;
  48376. /**
  48377. * Does a raycast in the physics world
  48378. * @param from when should the ray start?
  48379. * @param to when should the ray end?
  48380. * @returns PhysicsRaycastResult
  48381. */
  48382. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48383. }
  48384. }
  48385. declare module BABYLON {
  48386. interface AbstractScene {
  48387. /**
  48388. * The list of reflection probes added to the scene
  48389. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48390. */
  48391. reflectionProbes: Array<ReflectionProbe>;
  48392. /**
  48393. * Removes the given reflection probe from this scene.
  48394. * @param toRemove The reflection probe to remove
  48395. * @returns The index of the removed reflection probe
  48396. */
  48397. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48398. /**
  48399. * Adds the given reflection probe to this scene.
  48400. * @param newReflectionProbe The reflection probe to add
  48401. */
  48402. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48403. }
  48404. /**
  48405. * Class used to generate realtime reflection / refraction cube textures
  48406. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48407. */
  48408. export class ReflectionProbe {
  48409. /** defines the name of the probe */
  48410. name: string;
  48411. private _scene;
  48412. private _renderTargetTexture;
  48413. private _projectionMatrix;
  48414. private _viewMatrix;
  48415. private _target;
  48416. private _add;
  48417. private _attachedMesh;
  48418. private _invertYAxis;
  48419. /** Gets or sets probe position (center of the cube map) */
  48420. position: Vector3;
  48421. /**
  48422. * Creates a new reflection probe
  48423. * @param name defines the name of the probe
  48424. * @param size defines the texture resolution (for each face)
  48425. * @param scene defines the hosting scene
  48426. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48427. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48428. */
  48429. constructor(
  48430. /** defines the name of the probe */
  48431. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48432. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48433. samples: number;
  48434. /** Gets or sets the refresh rate to use (on every frame by default) */
  48435. refreshRate: number;
  48436. /**
  48437. * Gets the hosting scene
  48438. * @returns a Scene
  48439. */
  48440. getScene(): Scene;
  48441. /** Gets the internal CubeTexture used to render to */
  48442. readonly cubeTexture: RenderTargetTexture;
  48443. /** Gets the list of meshes to render */
  48444. readonly renderList: Nullable<AbstractMesh[]>;
  48445. /**
  48446. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48447. * @param mesh defines the mesh to attach to
  48448. */
  48449. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48450. /**
  48451. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48452. * @param renderingGroupId The rendering group id corresponding to its index
  48453. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48454. */
  48455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48456. /**
  48457. * Clean all associated resources
  48458. */
  48459. dispose(): void;
  48460. /**
  48461. * Converts the reflection probe information to a readable string for debug purpose.
  48462. * @param fullDetails Supports for multiple levels of logging within scene loading
  48463. * @returns the human readable reflection probe info
  48464. */
  48465. toString(fullDetails?: boolean): string;
  48466. /**
  48467. * Get the class name of the relfection probe.
  48468. * @returns "ReflectionProbe"
  48469. */
  48470. getClassName(): string;
  48471. /**
  48472. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48473. * @returns The JSON representation of the texture
  48474. */
  48475. serialize(): any;
  48476. /**
  48477. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48478. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48479. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48480. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48481. * @returns The parsed reflection probe if successful
  48482. */
  48483. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48484. }
  48485. }
  48486. declare module BABYLON {
  48487. /** @hidden */
  48488. export var _BabylonLoaderRegistered: boolean;
  48489. }
  48490. declare module BABYLON {
  48491. /**
  48492. * The Physically based simple base material of BJS.
  48493. *
  48494. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48495. * It is used as the base class for both the specGloss and metalRough conventions.
  48496. */
  48497. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48498. /**
  48499. * Number of Simultaneous lights allowed on the material.
  48500. */
  48501. maxSimultaneousLights: number;
  48502. /**
  48503. * If sets to true, disables all the lights affecting the material.
  48504. */
  48505. disableLighting: boolean;
  48506. /**
  48507. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48508. */
  48509. environmentTexture: BaseTexture;
  48510. /**
  48511. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48512. */
  48513. invertNormalMapX: boolean;
  48514. /**
  48515. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48516. */
  48517. invertNormalMapY: boolean;
  48518. /**
  48519. * Normal map used in the model.
  48520. */
  48521. normalTexture: BaseTexture;
  48522. /**
  48523. * Emissivie color used to self-illuminate the model.
  48524. */
  48525. emissiveColor: Color3;
  48526. /**
  48527. * Emissivie texture used to self-illuminate the model.
  48528. */
  48529. emissiveTexture: BaseTexture;
  48530. /**
  48531. * Occlusion Channel Strenght.
  48532. */
  48533. occlusionStrength: number;
  48534. /**
  48535. * Occlusion Texture of the material (adding extra occlusion effects).
  48536. */
  48537. occlusionTexture: BaseTexture;
  48538. /**
  48539. * Defines the alpha limits in alpha test mode.
  48540. */
  48541. alphaCutOff: number;
  48542. /**
  48543. * Gets the current double sided mode.
  48544. */
  48545. /**
  48546. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48547. */
  48548. doubleSided: boolean;
  48549. /**
  48550. * Stores the pre-calculated light information of a mesh in a texture.
  48551. */
  48552. lightmapTexture: BaseTexture;
  48553. /**
  48554. * If true, the light map contains occlusion information instead of lighting info.
  48555. */
  48556. useLightmapAsShadowmap: boolean;
  48557. /**
  48558. * Instantiates a new PBRMaterial instance.
  48559. *
  48560. * @param name The material name
  48561. * @param scene The scene the material will be use in.
  48562. */
  48563. constructor(name: string, scene: Scene);
  48564. getClassName(): string;
  48565. }
  48566. }
  48567. declare module BABYLON {
  48568. /**
  48569. * The PBR material of BJS following the metal roughness convention.
  48570. *
  48571. * This fits to the PBR convention in the GLTF definition:
  48572. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48573. */
  48574. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48575. /**
  48576. * The base color has two different interpretations depending on the value of metalness.
  48577. * When the material is a metal, the base color is the specific measured reflectance value
  48578. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48579. * of the material.
  48580. */
  48581. baseColor: Color3;
  48582. /**
  48583. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48584. * well as opacity information in the alpha channel.
  48585. */
  48586. baseTexture: BaseTexture;
  48587. /**
  48588. * Specifies the metallic scalar value of the material.
  48589. * Can also be used to scale the metalness values of the metallic texture.
  48590. */
  48591. metallic: number;
  48592. /**
  48593. * Specifies the roughness scalar value of the material.
  48594. * Can also be used to scale the roughness values of the metallic texture.
  48595. */
  48596. roughness: number;
  48597. /**
  48598. * Texture containing both the metallic value in the B channel and the
  48599. * roughness value in the G channel to keep better precision.
  48600. */
  48601. metallicRoughnessTexture: BaseTexture;
  48602. /**
  48603. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48604. *
  48605. * @param name The material name
  48606. * @param scene The scene the material will be use in.
  48607. */
  48608. constructor(name: string, scene: Scene);
  48609. /**
  48610. * Return the currrent class name of the material.
  48611. */
  48612. getClassName(): string;
  48613. /**
  48614. * Makes a duplicate of the current material.
  48615. * @param name - name to use for the new material.
  48616. */
  48617. clone(name: string): PBRMetallicRoughnessMaterial;
  48618. /**
  48619. * Serialize the material to a parsable JSON object.
  48620. */
  48621. serialize(): any;
  48622. /**
  48623. * Parses a JSON object correponding to the serialize function.
  48624. */
  48625. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48626. }
  48627. }
  48628. declare module BABYLON {
  48629. /**
  48630. * The PBR material of BJS following the specular glossiness convention.
  48631. *
  48632. * This fits to the PBR convention in the GLTF definition:
  48633. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48634. */
  48635. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48636. /**
  48637. * Specifies the diffuse color of the material.
  48638. */
  48639. diffuseColor: Color3;
  48640. /**
  48641. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48642. * channel.
  48643. */
  48644. diffuseTexture: BaseTexture;
  48645. /**
  48646. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48647. */
  48648. specularColor: Color3;
  48649. /**
  48650. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48651. */
  48652. glossiness: number;
  48653. /**
  48654. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48655. */
  48656. specularGlossinessTexture: BaseTexture;
  48657. /**
  48658. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48659. *
  48660. * @param name The material name
  48661. * @param scene The scene the material will be use in.
  48662. */
  48663. constructor(name: string, scene: Scene);
  48664. /**
  48665. * Return the currrent class name of the material.
  48666. */
  48667. getClassName(): string;
  48668. /**
  48669. * Makes a duplicate of the current material.
  48670. * @param name - name to use for the new material.
  48671. */
  48672. clone(name: string): PBRSpecularGlossinessMaterial;
  48673. /**
  48674. * Serialize the material to a parsable JSON object.
  48675. */
  48676. serialize(): any;
  48677. /**
  48678. * Parses a JSON object correponding to the serialize function.
  48679. */
  48680. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48681. }
  48682. }
  48683. declare module BABYLON {
  48684. /**
  48685. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48686. * It can help converting any input color in a desired output one. This can then be used to create effects
  48687. * from sepia, black and white to sixties or futuristic rendering...
  48688. *
  48689. * The only supported format is currently 3dl.
  48690. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48691. */
  48692. export class ColorGradingTexture extends BaseTexture {
  48693. /**
  48694. * The current texture matrix. (will always be identity in color grading texture)
  48695. */
  48696. private _textureMatrix;
  48697. /**
  48698. * The texture URL.
  48699. */
  48700. url: string;
  48701. /**
  48702. * Empty line regex stored for GC.
  48703. */
  48704. private static _noneEmptyLineRegex;
  48705. private _engine;
  48706. /**
  48707. * Instantiates a ColorGradingTexture from the following parameters.
  48708. *
  48709. * @param url The location of the color gradind data (currently only supporting 3dl)
  48710. * @param scene The scene the texture will be used in
  48711. */
  48712. constructor(url: string, scene: Scene);
  48713. /**
  48714. * Returns the texture matrix used in most of the material.
  48715. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48716. */
  48717. getTextureMatrix(): Matrix;
  48718. /**
  48719. * Occurs when the file being loaded is a .3dl LUT file.
  48720. */
  48721. private load3dlTexture;
  48722. /**
  48723. * Starts the loading process of the texture.
  48724. */
  48725. private loadTexture;
  48726. /**
  48727. * Clones the color gradind texture.
  48728. */
  48729. clone(): ColorGradingTexture;
  48730. /**
  48731. * Called during delayed load for textures.
  48732. */
  48733. delayLoad(): void;
  48734. /**
  48735. * Parses a color grading texture serialized by Babylon.
  48736. * @param parsedTexture The texture information being parsedTexture
  48737. * @param scene The scene to load the texture in
  48738. * @param rootUrl The root url of the data assets to load
  48739. * @return A color gradind texture
  48740. */
  48741. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48742. /**
  48743. * Serializes the LUT texture to json format.
  48744. */
  48745. serialize(): any;
  48746. }
  48747. }
  48748. declare module BABYLON {
  48749. /**
  48750. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48751. */
  48752. export class EquiRectangularCubeTexture extends BaseTexture {
  48753. /** The six faces of the cube. */
  48754. private static _FacesMapping;
  48755. private _noMipmap;
  48756. private _onLoad;
  48757. private _onError;
  48758. /** The size of the cubemap. */
  48759. private _size;
  48760. /** The buffer of the image. */
  48761. private _buffer;
  48762. /** The width of the input image. */
  48763. private _width;
  48764. /** The height of the input image. */
  48765. private _height;
  48766. /** The URL to the image. */
  48767. url: string;
  48768. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48769. coordinatesMode: number;
  48770. /**
  48771. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48772. * @param url The location of the image
  48773. * @param scene The scene the texture will be used in
  48774. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48775. * @param noMipmap Forces to not generate the mipmap if true
  48776. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48777. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48778. * @param onLoad — defines a callback called when texture is loaded
  48779. * @param onError — defines a callback called if there is an error
  48780. */
  48781. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48782. /**
  48783. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48784. */
  48785. private loadImage;
  48786. /**
  48787. * Convert the image buffer into a cubemap and create a CubeTexture.
  48788. */
  48789. private loadTexture;
  48790. /**
  48791. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48792. * @param buffer The ArrayBuffer that should be converted.
  48793. * @returns The buffer as Float32Array.
  48794. */
  48795. private getFloat32ArrayFromArrayBuffer;
  48796. /**
  48797. * Get the current class name of the texture useful for serialization or dynamic coding.
  48798. * @returns "EquiRectangularCubeTexture"
  48799. */
  48800. getClassName(): string;
  48801. /**
  48802. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48803. * @returns A clone of the current EquiRectangularCubeTexture.
  48804. */
  48805. clone(): EquiRectangularCubeTexture;
  48806. }
  48807. }
  48808. declare module BABYLON {
  48809. /**
  48810. * Based on jsTGALoader - Javascript loader for TGA file
  48811. * By Vincent Thibault
  48812. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48813. */
  48814. export class TGATools {
  48815. private static _TYPE_INDEXED;
  48816. private static _TYPE_RGB;
  48817. private static _TYPE_GREY;
  48818. private static _TYPE_RLE_INDEXED;
  48819. private static _TYPE_RLE_RGB;
  48820. private static _TYPE_RLE_GREY;
  48821. private static _ORIGIN_MASK;
  48822. private static _ORIGIN_SHIFT;
  48823. private static _ORIGIN_BL;
  48824. private static _ORIGIN_BR;
  48825. private static _ORIGIN_UL;
  48826. private static _ORIGIN_UR;
  48827. /**
  48828. * Gets the header of a TGA file
  48829. * @param data defines the TGA data
  48830. * @returns the header
  48831. */
  48832. static GetTGAHeader(data: Uint8Array): any;
  48833. /**
  48834. * Uploads TGA content to a Babylon Texture
  48835. * @hidden
  48836. */
  48837. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48838. /** @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;
  48839. /** @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;
  48840. /** @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;
  48841. /** @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;
  48842. /** @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;
  48843. /** @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;
  48844. }
  48845. }
  48846. declare module BABYLON {
  48847. /**
  48848. * Implementation of the TGA Texture Loader.
  48849. * @hidden
  48850. */
  48851. export class _TGATextureLoader implements IInternalTextureLoader {
  48852. /**
  48853. * Defines wether the loader supports cascade loading the different faces.
  48854. */
  48855. readonly supportCascades: boolean;
  48856. /**
  48857. * This returns if the loader support the current file information.
  48858. * @param extension defines the file extension of the file being loaded
  48859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48860. * @param fallback defines the fallback internal texture if any
  48861. * @param isBase64 defines whether the texture is encoded as a base64
  48862. * @param isBuffer defines whether the texture data are stored as a buffer
  48863. * @returns true if the loader can load the specified file
  48864. */
  48865. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48866. /**
  48867. * Transform the url before loading if required.
  48868. * @param rootUrl the url of the texture
  48869. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48870. * @returns the transformed texture
  48871. */
  48872. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48873. /**
  48874. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48875. * @param rootUrl the url of the texture
  48876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48877. * @returns the fallback texture
  48878. */
  48879. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48880. /**
  48881. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48882. * @param data contains the texture data
  48883. * @param texture defines the BabylonJS internal texture
  48884. * @param createPolynomials will be true if polynomials have been requested
  48885. * @param onLoad defines the callback to trigger once the texture is ready
  48886. * @param onError defines the callback to trigger in case of error
  48887. */
  48888. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48889. /**
  48890. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48891. * @param data contains the texture data
  48892. * @param texture defines the BabylonJS internal texture
  48893. * @param callback defines the method to call once ready to upload
  48894. */
  48895. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48896. }
  48897. }
  48898. declare module BABYLON {
  48899. /**
  48900. * 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.
  48901. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48902. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48903. */
  48904. export class CustomProceduralTexture extends ProceduralTexture {
  48905. private _animate;
  48906. private _time;
  48907. private _config;
  48908. private _texturePath;
  48909. /**
  48910. * Instantiates a new Custom Procedural Texture.
  48911. * 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.
  48912. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48913. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48914. * @param name Define the name of the texture
  48915. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48916. * @param size Define the size of the texture to create
  48917. * @param scene Define the scene the texture belongs to
  48918. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48919. * @param generateMipMaps Define if the texture should creates mip maps or not
  48920. */
  48921. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48922. private _loadJson;
  48923. /**
  48924. * Is the texture ready to be used ? (rendered at least once)
  48925. * @returns true if ready, otherwise, false.
  48926. */
  48927. isReady(): boolean;
  48928. /**
  48929. * Render the texture to its associated render target.
  48930. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48931. */
  48932. render(useCameraPostProcess?: boolean): void;
  48933. /**
  48934. * Update the list of dependant textures samplers in the shader.
  48935. */
  48936. updateTextures(): void;
  48937. /**
  48938. * Update the uniform values of the procedural texture in the shader.
  48939. */
  48940. updateShaderUniforms(): void;
  48941. /**
  48942. * Define if the texture animates or not.
  48943. */
  48944. animate: boolean;
  48945. }
  48946. }
  48947. declare module BABYLON {
  48948. /** @hidden */
  48949. export var noisePixelShader: {
  48950. name: string;
  48951. shader: string;
  48952. };
  48953. }
  48954. declare module BABYLON {
  48955. /**
  48956. * Class used to generate noise procedural textures
  48957. */
  48958. export class NoiseProceduralTexture extends ProceduralTexture {
  48959. private _time;
  48960. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48961. brightness: number;
  48962. /** Defines the number of octaves to process */
  48963. octaves: number;
  48964. /** Defines the level of persistence (0.8 by default) */
  48965. persistence: number;
  48966. /** Gets or sets animation speed factor (default is 1) */
  48967. animationSpeedFactor: number;
  48968. /**
  48969. * Creates a new NoiseProceduralTexture
  48970. * @param name defines the name fo the texture
  48971. * @param size defines the size of the texture (default is 256)
  48972. * @param scene defines the hosting scene
  48973. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48974. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48975. */
  48976. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48977. private _updateShaderUniforms;
  48978. protected _getDefines(): string;
  48979. /** Generate the current state of the procedural texture */
  48980. render(useCameraPostProcess?: boolean): void;
  48981. /**
  48982. * Serializes this noise procedural texture
  48983. * @returns a serialized noise procedural texture object
  48984. */
  48985. serialize(): any;
  48986. /**
  48987. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48988. * @param parsedTexture defines parsed texture data
  48989. * @param scene defines the current scene
  48990. * @param rootUrl defines the root URL containing noise procedural texture information
  48991. * @returns a parsed NoiseProceduralTexture
  48992. */
  48993. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48994. }
  48995. }
  48996. declare module BABYLON {
  48997. /**
  48998. * Raw cube texture where the raw buffers are passed in
  48999. */
  49000. export class RawCubeTexture extends CubeTexture {
  49001. /**
  49002. * Creates a cube texture where the raw buffers are passed in.
  49003. * @param scene defines the scene the texture is attached to
  49004. * @param data defines the array of data to use to create each face
  49005. * @param size defines the size of the textures
  49006. * @param format defines the format of the data
  49007. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49008. * @param generateMipMaps defines if the engine should generate the mip levels
  49009. * @param invertY defines if data must be stored with Y axis inverted
  49010. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49011. * @param compression defines the compression used (null by default)
  49012. */
  49013. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49014. /**
  49015. * Updates the raw cube texture.
  49016. * @param data defines the data to store
  49017. * @param format defines the data format
  49018. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49019. * @param invertY defines if data must be stored with Y axis inverted
  49020. * @param compression defines the compression used (null by default)
  49021. * @param level defines which level of the texture to update
  49022. */
  49023. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49024. /**
  49025. * Updates a raw cube texture with RGBD encoded data.
  49026. * @param data defines the array of data [mipmap][face] to use to create each face
  49027. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49028. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49029. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49030. * @returns a promsie that resolves when the operation is complete
  49031. */
  49032. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49033. /**
  49034. * Clones the raw cube texture.
  49035. * @return a new cube texture
  49036. */
  49037. clone(): CubeTexture;
  49038. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49039. }
  49040. }
  49041. declare module BABYLON {
  49042. /**
  49043. * Class used to store 3D textures containing user data
  49044. */
  49045. export class RawTexture3D extends Texture {
  49046. /** Gets or sets the texture format to use */
  49047. format: number;
  49048. private _engine;
  49049. /**
  49050. * Create a new RawTexture3D
  49051. * @param data defines the data of the texture
  49052. * @param width defines the width of the texture
  49053. * @param height defines the height of the texture
  49054. * @param depth defines the depth of the texture
  49055. * @param format defines the texture format to use
  49056. * @param scene defines the hosting scene
  49057. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49058. * @param invertY defines if texture must be stored with Y axis inverted
  49059. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49060. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49061. */
  49062. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49063. /** Gets or sets the texture format to use */
  49064. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49065. /**
  49066. * Update the texture with new data
  49067. * @param data defines the data to store in the texture
  49068. */
  49069. update(data: ArrayBufferView): void;
  49070. }
  49071. }
  49072. declare module BABYLON {
  49073. /**
  49074. * Creates a refraction texture used by refraction channel of the standard material.
  49075. * It is like a mirror but to see through a material.
  49076. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49077. */
  49078. export class RefractionTexture extends RenderTargetTexture {
  49079. /**
  49080. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49081. * 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.
  49082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49083. */
  49084. refractionPlane: Plane;
  49085. /**
  49086. * Define how deep under the surface we should see.
  49087. */
  49088. depth: number;
  49089. /**
  49090. * Creates a refraction texture used by refraction channel of the standard material.
  49091. * It is like a mirror but to see through a material.
  49092. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49093. * @param name Define the texture name
  49094. * @param size Define the size of the underlying texture
  49095. * @param scene Define the scene the refraction belongs to
  49096. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49097. */
  49098. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49099. /**
  49100. * Clone the refraction texture.
  49101. * @returns the cloned texture
  49102. */
  49103. clone(): RefractionTexture;
  49104. /**
  49105. * Serialize the texture to a JSON representation you could use in Parse later on
  49106. * @returns the serialized JSON representation
  49107. */
  49108. serialize(): any;
  49109. }
  49110. }
  49111. declare module BABYLON {
  49112. /**
  49113. * Defines the options related to the creation of an HtmlElementTexture
  49114. */
  49115. export interface IHtmlElementTextureOptions {
  49116. /**
  49117. * Defines wether mip maps should be created or not.
  49118. */
  49119. generateMipMaps?: boolean;
  49120. /**
  49121. * Defines the sampling mode of the texture.
  49122. */
  49123. samplingMode?: number;
  49124. /**
  49125. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49126. */
  49127. engine: Nullable<Engine>;
  49128. /**
  49129. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49130. */
  49131. scene: Nullable<Scene>;
  49132. }
  49133. /**
  49134. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49135. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49136. * is automatically managed.
  49137. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49138. * in your application.
  49139. *
  49140. * As the update is not automatic, you need to call them manually.
  49141. */
  49142. export class HtmlElementTexture extends BaseTexture {
  49143. /**
  49144. * The texture URL.
  49145. */
  49146. element: HTMLVideoElement | HTMLCanvasElement;
  49147. private static readonly DefaultOptions;
  49148. private _textureMatrix;
  49149. private _engine;
  49150. private _isVideo;
  49151. private _generateMipMaps;
  49152. private _samplingMode;
  49153. /**
  49154. * Instantiates a HtmlElementTexture from the following parameters.
  49155. *
  49156. * @param name Defines the name of the texture
  49157. * @param element Defines the video or canvas the texture is filled with
  49158. * @param options Defines the other none mandatory texture creation options
  49159. */
  49160. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49161. private _createInternalTexture;
  49162. /**
  49163. * Returns the texture matrix used in most of the material.
  49164. */
  49165. getTextureMatrix(): Matrix;
  49166. /**
  49167. * Updates the content of the texture.
  49168. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49169. */
  49170. update(invertY?: Nullable<boolean>): void;
  49171. }
  49172. }
  49173. declare module BABYLON {
  49174. /**
  49175. * Enum used to define the target of a block
  49176. */
  49177. export enum NodeMaterialBlockTargets {
  49178. /** Vertex shader */
  49179. Vertex = 1,
  49180. /** Fragment shader */
  49181. Fragment = 2,
  49182. /** Vertex and Fragment */
  49183. VertexAndFragment = 3
  49184. }
  49185. }
  49186. declare module BABYLON {
  49187. /**
  49188. * Defines the kind of connection point for node based material
  49189. */
  49190. export enum NodeMaterialBlockConnectionPointTypes {
  49191. /** Float */
  49192. Float = 1,
  49193. /** Int */
  49194. Int = 2,
  49195. /** Vector2 */
  49196. Vector2 = 4,
  49197. /** Vector3 */
  49198. Vector3 = 8,
  49199. /** Vector4 */
  49200. Vector4 = 16,
  49201. /** Color3 */
  49202. Color3 = 32,
  49203. /** Color4 */
  49204. Color4 = 64,
  49205. /** Matrix */
  49206. Matrix = 128,
  49207. /** Texture */
  49208. Texture = 256,
  49209. /** Texture3D */
  49210. Texture3D = 512,
  49211. /** Vector3 or Color3 */
  49212. Vector3OrColor3 = 40,
  49213. /** Vector3 or Vector4 */
  49214. Vector3OrVector4 = 24,
  49215. /** Vector4 or Color4 */
  49216. Vector4OrColor4 = 80,
  49217. /** Color3 or Color4 */
  49218. Color3OrColor4 = 96,
  49219. /** Vector3 or Color3 */
  49220. Vector3OrColor3OrVector4OrColor4 = 120
  49221. }
  49222. }
  49223. declare module BABYLON {
  49224. /**
  49225. * Enum used to define well known values e.g. values automatically provided by the system
  49226. */
  49227. export enum NodeMaterialWellKnownValues {
  49228. /** World */
  49229. World = 1,
  49230. /** View */
  49231. View = 2,
  49232. /** Projection */
  49233. Projection = 3,
  49234. /** ViewProjection */
  49235. ViewProjection = 4,
  49236. /** WorldView */
  49237. WorldView = 5,
  49238. /** WorldViewProjection */
  49239. WorldViewProjection = 6,
  49240. /** Will be filled by the block itself */
  49241. BlockBased = 7
  49242. }
  49243. }
  49244. declare module BABYLON {
  49245. /**
  49246. * Class used to store shared data between 2 NodeMaterialBuildState
  49247. */
  49248. export class NodeMaterialBuildStateSharedData {
  49249. /**
  49250. * Gets the list of emitted varyings
  49251. */
  49252. varyings: string[];
  49253. /**
  49254. * Gets the varying declaration string
  49255. */
  49256. varyingDeclaration: string;
  49257. /**
  49258. * Uniform connection points
  49259. */
  49260. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  49261. /**
  49262. * Bindable blocks (Blocks that need to set data to the effect)
  49263. */
  49264. bindableBlocks: NodeMaterialBlock[];
  49265. /**
  49266. * List of blocks that can provide a compilation fallback
  49267. */
  49268. blocksWithFallbacks: NodeMaterialBlock[];
  49269. /**
  49270. * List of blocks that can provide a define update
  49271. */
  49272. blocksWithDefines: NodeMaterialBlock[];
  49273. /**
  49274. * List of blocks that can provide a repeatable content
  49275. */
  49276. repeatableContentBlocks: NodeMaterialBlock[];
  49277. /**
  49278. * List of blocks that can block the isReady function for the material
  49279. */
  49280. blockingBlocks: NodeMaterialBlock[];
  49281. /**
  49282. * Build Id used to avoid multiple recompilations
  49283. */
  49284. buildId: number;
  49285. /** List of emitted variables */
  49286. variableNames: {
  49287. [key: string]: number;
  49288. };
  49289. /** List of emitted defines */
  49290. defineNames: {
  49291. [key: string]: number;
  49292. };
  49293. /** Should emit comments? */
  49294. emitComments: boolean;
  49295. /** Emit build activity */
  49296. verbose: boolean;
  49297. /**
  49298. * Gets the compilation hints emitted at compilation time
  49299. */
  49300. hints: {
  49301. needWorldViewMatrix: boolean;
  49302. needWorldViewProjectionMatrix: boolean;
  49303. needAlphaBlending: boolean;
  49304. needAlphaTesting: boolean;
  49305. };
  49306. /**
  49307. * List of compilation checks
  49308. */
  49309. checks: {
  49310. emitVertex: boolean;
  49311. emitFragment: boolean;
  49312. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  49313. };
  49314. /** Creates a new shared data */
  49315. constructor();
  49316. /**
  49317. * Emits console errors and exceptions if there is a failing check
  49318. */
  49319. emitErrors(): void;
  49320. }
  49321. }
  49322. declare module BABYLON {
  49323. /**
  49324. * Class used to store node based material build state
  49325. */
  49326. export class NodeMaterialBuildState {
  49327. /**
  49328. * Gets the list of emitted attributes
  49329. */
  49330. attributes: string[];
  49331. /**
  49332. * Gets the list of emitted uniforms
  49333. */
  49334. uniforms: string[];
  49335. /**
  49336. * Gets the list of emitted samplers
  49337. */
  49338. samplers: string[];
  49339. /**
  49340. * Gets the list of emitted functions
  49341. */
  49342. functions: {
  49343. [key: string]: string;
  49344. };
  49345. /**
  49346. * Gets the target of the compilation state
  49347. */
  49348. target: NodeMaterialBlockTargets;
  49349. /**
  49350. * Shared data between multiple NodeMaterialBuildState instances
  49351. */
  49352. sharedData: NodeMaterialBuildStateSharedData;
  49353. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  49354. private _attributeDeclaration;
  49355. private _uniformDeclaration;
  49356. private _samplerDeclaration;
  49357. private _varyingTransfer;
  49358. private _repeatableContentAnchorIndex;
  49359. /** @hidden */ private _builtCompilationString: string;
  49360. /**
  49361. * Gets the emitted compilation strings
  49362. */
  49363. compilationString: string;
  49364. /**
  49365. * Finalize the compilation strings
  49366. * @param state defines the current compilation state
  49367. */
  49368. finalize(state: NodeMaterialBuildState): void;
  49369. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  49370. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  49371. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  49372. /** @hidden */ private _excludeVariableName(name: string): void;
  49373. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  49374. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  49375. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  49376. replaceStrings?: {
  49377. search: RegExp;
  49378. replace: string;
  49379. }[];
  49380. }): string;
  49381. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  49382. repeatKey?: string;
  49383. removeAttributes?: boolean;
  49384. removeUniforms?: boolean;
  49385. removeVaryings?: boolean;
  49386. removeIfDef?: boolean;
  49387. replaceStrings?: {
  49388. search: RegExp;
  49389. replace: string;
  49390. }[];
  49391. }): void;
  49392. /** @hidden */ private _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  49393. private _emitDefine;
  49394. /** @hidden */ private _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  49395. }
  49396. }
  49397. declare module BABYLON {
  49398. /**
  49399. * Root class for all node material optimizers
  49400. */
  49401. export class NodeMaterialOptimizer {
  49402. /**
  49403. * Function used to optimize a NodeMaterial graph
  49404. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  49405. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  49406. */
  49407. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  49408. }
  49409. }
  49410. declare module BABYLON {
  49411. /** @hidden */
  49412. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  49413. /** BONES */
  49414. NUM_BONE_INFLUENCERS: number;
  49415. BonesPerMesh: number;
  49416. BONETEXTURE: boolean;
  49417. /** MORPH TARGETS */
  49418. MORPHTARGETS: boolean;
  49419. MORPHTARGETS_NORMAL: boolean;
  49420. MORPHTARGETS_TANGENT: boolean;
  49421. NUM_MORPH_INFLUENCERS: number;
  49422. /** IMAGE PROCESSING */
  49423. IMAGEPROCESSING: boolean;
  49424. VIGNETTE: boolean;
  49425. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49426. VIGNETTEBLENDMODEOPAQUE: boolean;
  49427. TONEMAPPING: boolean;
  49428. TONEMAPPING_ACES: boolean;
  49429. CONTRAST: boolean;
  49430. EXPOSURE: boolean;
  49431. COLORCURVES: boolean;
  49432. COLORGRADING: boolean;
  49433. COLORGRADING3D: boolean;
  49434. SAMPLER3DGREENDEPTH: boolean;
  49435. SAMPLER3DBGRMAP: boolean;
  49436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49437. constructor();
  49438. setValue(name: string, value: boolean): void;
  49439. }
  49440. /**
  49441. * Class used to configure NodeMaterial
  49442. */
  49443. export interface INodeMaterialOptions {
  49444. /**
  49445. * Defines if blocks should emit comments
  49446. */
  49447. emitComments: boolean;
  49448. }
  49449. /**
  49450. * Class used to create a node based material built by assembling shader blocks
  49451. */
  49452. export class NodeMaterial extends PushMaterial {
  49453. private _options;
  49454. private _vertexCompilationState;
  49455. private _fragmentCompilationState;
  49456. private _sharedData;
  49457. private _buildId;
  49458. private _buildWasSuccessful;
  49459. private _cachedWorldViewMatrix;
  49460. private _cachedWorldViewProjectionMatrix;
  49461. private _textureConnectionPoints;
  49462. private _optimizers;
  49463. /**
  49464. * Defines the maximum number of lights that can be used in the material
  49465. */
  49466. maxSimultaneousLights: number;
  49467. /**
  49468. * Observable raised when the material is built
  49469. */
  49470. onBuildObservable: Observable<NodeMaterial>;
  49471. /**
  49472. * Gets or sets the root nodes of the material vertex shader
  49473. */ private _vertexOutputNodes: NodeMaterialBlock[];
  49474. /**
  49475. * Gets or sets the root nodes of the material fragment (pixel) shader
  49476. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  49477. /** Gets or sets options to control the node material overall behavior */
  49478. options: INodeMaterialOptions;
  49479. /**
  49480. * Default configuration related to image processing available in the standard Material.
  49481. */
  49482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49483. /**
  49484. * Gets the image processing configuration used either in this material.
  49485. */
  49486. /**
  49487. * Sets the Default image processing configuration used either in the this material.
  49488. *
  49489. * If sets to null, the scene one is in use.
  49490. */
  49491. imageProcessingConfiguration: ImageProcessingConfiguration;
  49492. /**
  49493. * Create a new node based material
  49494. * @param name defines the material name
  49495. * @param scene defines the hosting scene
  49496. * @param options defines creation option
  49497. */
  49498. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  49499. /**
  49500. * Gets the current class name of the material e.g. "NodeMaterial"
  49501. * @returns the class name
  49502. */
  49503. getClassName(): string;
  49504. /**
  49505. * Keep track of the image processing observer to allow dispose and replace.
  49506. */
  49507. private _imageProcessingObserver;
  49508. /**
  49509. * Attaches a new image processing configuration to the Standard Material.
  49510. * @param configuration
  49511. */
  49512. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49513. /**
  49514. * Adds a new optimizer to the list of optimizers
  49515. * @param optimizer defines the optimizers to add
  49516. * @returns the current material
  49517. */
  49518. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  49519. /**
  49520. * Remove an optimizer from the list of optimizers
  49521. * @param optimizer defines the optimizers to remove
  49522. * @returns the current material
  49523. */
  49524. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  49525. /**
  49526. * Add a new block to the list of output nodes
  49527. * @param node defines the node to add
  49528. * @returns the current material
  49529. */
  49530. addOutputNode(node: NodeMaterialBlock): this;
  49531. /**
  49532. * Remove a block from the list of root nodes
  49533. * @param node defines the node to remove
  49534. * @returns the current material
  49535. */
  49536. removeOutputNode(node: NodeMaterialBlock): this;
  49537. private _addVertexOutputNode;
  49538. private _removeVertexOutputNode;
  49539. private _addFragmentOutputNode;
  49540. private _removeFragmentOutputNode;
  49541. /**
  49542. * Specifies if the material will require alpha blending
  49543. * @returns a boolean specifying if alpha blending is needed
  49544. */
  49545. needAlphaBlending(): boolean;
  49546. /**
  49547. * Specifies if this material should be rendered in alpha test mode
  49548. * @returns a boolean specifying if an alpha test is needed.
  49549. */
  49550. needAlphaTesting(): boolean;
  49551. private _initializeBlock;
  49552. private _resetDualBlocks;
  49553. /**
  49554. * Build the material and generates the inner effect
  49555. * @param verbose defines if the build should log activity
  49556. */
  49557. build(verbose?: boolean): void;
  49558. /**
  49559. * Runs an otpimization phase to try to improve the shader code
  49560. */
  49561. optimize(): void;
  49562. private _prepareDefinesForAttributes;
  49563. /**
  49564. * Get if the submesh is ready to be used and all its information available.
  49565. * Child classes can use it to update shaders
  49566. * @param mesh defines the mesh to check
  49567. * @param subMesh defines which submesh to check
  49568. * @param useInstances specifies that instances should be used
  49569. * @returns a boolean indicating that the submesh is ready or not
  49570. */
  49571. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49572. /**
  49573. * Binds the world matrix to the material
  49574. * @param world defines the world transformation matrix
  49575. */
  49576. bindOnlyWorldMatrix(world: Matrix): void;
  49577. /**
  49578. * Binds the submesh to this material by preparing the effect and shader to draw
  49579. * @param world defines the world transformation matrix
  49580. * @param mesh defines the mesh containing the submesh
  49581. * @param subMesh defines the submesh to bind the material to
  49582. */
  49583. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49584. /**
  49585. * Gets the active textures from the material
  49586. * @returns an array of textures
  49587. */
  49588. getActiveTextures(): BaseTexture[];
  49589. /**
  49590. * Specifies if the material uses a texture
  49591. * @param texture defines the texture to check against the material
  49592. * @returns a boolean specifying if the material uses the texture
  49593. */
  49594. hasTexture(texture: BaseTexture): boolean;
  49595. /**
  49596. * Disposes the material
  49597. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  49598. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  49599. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  49600. */
  49601. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  49602. }
  49603. }
  49604. declare module BABYLON {
  49605. /**
  49606. * Defines a block that can be used inside a node based material
  49607. */
  49608. export class NodeMaterialBlock {
  49609. private _buildId;
  49610. private _target;
  49611. private _isFinalMerger;
  49612. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  49613. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  49614. /**
  49615. * Gets or sets the name of the block
  49616. */
  49617. name: string;
  49618. /**
  49619. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  49620. */
  49621. readonly isFinalMerger: boolean;
  49622. /**
  49623. * Gets or sets the build Id
  49624. */
  49625. buildId: number;
  49626. /**
  49627. * Gets or sets the target of the block
  49628. */
  49629. target: NodeMaterialBlockTargets;
  49630. /**
  49631. * Gets the list of input points
  49632. */
  49633. readonly inputs: NodeMaterialConnectionPoint[];
  49634. /** Gets the list of output points */
  49635. readonly outputs: NodeMaterialConnectionPoint[];
  49636. /**
  49637. * Find an input by its name
  49638. * @param name defines the name of the input to look for
  49639. * @returns the input or null if not found
  49640. */
  49641. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  49642. /**
  49643. * Find an output by its name
  49644. * @param name defines the name of the outputto look for
  49645. * @returns the output or null if not found
  49646. */
  49647. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  49648. /**
  49649. * Creates a new NodeMaterialBlock
  49650. * @param name defines the block name
  49651. * @param target defines the target of that block (Vertex by default)
  49652. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  49653. */
  49654. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  49655. /**
  49656. * Initialize the block and prepare the context for build
  49657. * @param state defines the state that will be used for the build
  49658. */
  49659. initialize(state: NodeMaterialBuildState): void;
  49660. /**
  49661. * Bind data to effect. Will only be called for blocks with isBindable === true
  49662. * @param effect defines the effect to bind data to
  49663. * @param nodeMaterial defines the hosting NodeMaterial
  49664. * @param mesh defines the mesh that will be rendered
  49665. */
  49666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  49667. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  49668. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  49669. protected _writeFloat(value: number): string;
  49670. /**
  49671. * Gets the current class name e.g. "NodeMaterialBlock"
  49672. * @returns the class name
  49673. */
  49674. getClassName(): string;
  49675. /**
  49676. * Register a new input. Must be called inside a block constructor
  49677. * @param name defines the connection point name
  49678. * @param type defines the connection point type
  49679. * @param isOptional defines a boolean indicating that this input can be omitted
  49680. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  49681. * @returns the current block
  49682. */
  49683. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  49684. /**
  49685. * Register a new output. Must be called inside a block constructor
  49686. * @param name defines the connection point name
  49687. * @param type defines the connection point type
  49688. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  49689. * @returns the current block
  49690. */
  49691. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  49692. /**
  49693. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  49694. * @param forOutput defines an optional connection point to check compatibility with
  49695. * @returns the first available input or null
  49696. */
  49697. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  49698. /**
  49699. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  49700. * @param forBlock defines an optional block to check compatibility with
  49701. * @returns the first available input or null
  49702. */
  49703. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  49704. /**
  49705. * Connect current block with another block
  49706. * @param other defines the block to connect with
  49707. * @param options define the various options to help pick the right connections
  49708. * @returns the current block
  49709. */
  49710. connectTo(other: NodeMaterialBlock, options?: {
  49711. input?: string;
  49712. output?: string;
  49713. outputSwizzle?: string;
  49714. }): this | undefined;
  49715. protected _buildBlock(state: NodeMaterialBuildState): void;
  49716. /**
  49717. * Add potential fallbacks if shader compilation fails
  49718. * @param mesh defines the mesh to be rendered
  49719. * @param fallbacks defines the current prioritized list of fallbacks
  49720. */
  49721. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  49722. /**
  49723. * Update defines for shader compilation
  49724. * @param mesh defines the mesh to be rendered
  49725. * @param nodeMaterial defines the node material requesting the update
  49726. * @param defines defines the material defines to update
  49727. * @param useInstances specifies that instances should be used
  49728. */
  49729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  49730. /**
  49731. * Lets the block try to connect some inputs automatically
  49732. */
  49733. autoConfigure(): void;
  49734. /**
  49735. * Function called when a block is declared as repeatable content generator
  49736. * @param vertexShaderState defines the current compilation state for the vertex shader
  49737. * @param fragmentShaderState defines the current compilation state for the fragment shader
  49738. * @param mesh defines the mesh to be rendered
  49739. * @param defines defines the material defines to update
  49740. */
  49741. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  49742. /**
  49743. * Checks if the block is ready
  49744. * @param mesh defines the mesh to be rendered
  49745. * @param nodeMaterial defines the node material requesting the update
  49746. * @param defines defines the material defines to update
  49747. * @param useInstances specifies that instances should be used
  49748. * @returns true if the block is ready
  49749. */
  49750. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  49751. /**
  49752. * Compile the current node and generate the shader code
  49753. * @param state defines the current compilation state (uniforms, samplers, current string)
  49754. * @returns the current block
  49755. */
  49756. build(state: NodeMaterialBuildState): this | undefined;
  49757. }
  49758. }
  49759. declare module BABYLON {
  49760. /**
  49761. * Defines a connection point for a block
  49762. */
  49763. export class NodeMaterialConnectionPoint {
  49764. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  49765. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  49766. private _associatedVariableName;
  49767. private _endpoints;
  49768. private _storedValue;
  49769. private _valueCallback;
  49770. private _isVarying;
  49771. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  49772. /**
  49773. * Gets or sets the connection point type (default is float)
  49774. */
  49775. type: NodeMaterialBlockConnectionPointTypes;
  49776. /**
  49777. * Gets or sets the connection point name
  49778. */
  49779. name: string;
  49780. /**
  49781. * Gets or sets the swizzle to apply to this connection point when reading or writing
  49782. */
  49783. swizzle: string;
  49784. /**
  49785. * Gets or sets a boolean indicating that this connection point can be omitted
  49786. */
  49787. isOptional: boolean;
  49788. /**
  49789. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  49790. */
  49791. define: string;
  49792. /** Gets or sets the target of that connection point */
  49793. target: NodeMaterialBlockTargets;
  49794. /**
  49795. * Gets or sets the value of that point.
  49796. * Please note that this value will be ignored if valueCallback is defined
  49797. */
  49798. value: any;
  49799. /**
  49800. * Gets or sets a callback used to get the value of that point.
  49801. * Please note that setting this value will force the connection point to ignore the value property
  49802. */
  49803. valueCallback: () => any;
  49804. /**
  49805. * Gets or sets the associated variable name in the shader
  49806. */
  49807. associatedVariableName: string;
  49808. /**
  49809. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  49810. * In this case the connection point name must be the name of the uniform to use.
  49811. * Can only be set on inputs
  49812. */
  49813. isUniform: boolean;
  49814. /**
  49815. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  49816. * In this case the connection point name must be the name of the attribute to use
  49817. * Can only be set on inputs
  49818. */
  49819. isAttribute: boolean;
  49820. /**
  49821. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  49822. * Can only be set on exit points
  49823. */
  49824. isVarying: boolean;
  49825. /** Get the other side of the connection (if any) */
  49826. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  49827. /** Get the block that owns this connection point */
  49828. readonly ownerBlock: NodeMaterialBlock;
  49829. /** Get the block connected on the other side of this connection (if any) */
  49830. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  49831. /** Get the block connected on the endpoints of this connection (if any) */
  49832. readonly connectedBlocks: Array<NodeMaterialBlock>;
  49833. /**
  49834. * Creates a new connection point
  49835. * @param name defines the connection point name
  49836. * @param ownerBlock defines the block hosting this connection point
  49837. */
  49838. constructor(name: string, ownerBlock: NodeMaterialBlock);
  49839. /**
  49840. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  49841. * @returns the class name
  49842. */
  49843. getClassName(): string;
  49844. /**
  49845. * Set the source of this connection point to a vertex attribute
  49846. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  49847. * @returns the current connection point
  49848. */
  49849. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  49850. /**
  49851. * Set the source of this connection point to a well known value
  49852. * @param value define the well known value to use (world, view, etc...)
  49853. * @returns the current connection point
  49854. */
  49855. setAsWellKnownValue(value: NodeMaterialWellKnownValues): NodeMaterialConnectionPoint;
  49856. private _getTypeLength;
  49857. /**
  49858. * Connect this point to another connection point
  49859. * @param connectionPoint defines the other connection point
  49860. * @returns the current connection point
  49861. */
  49862. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  49863. /**
  49864. * Disconnect this point from one of his endpoint
  49865. * @param endpoint defines the other connection point
  49866. * @returns the current connection point
  49867. */
  49868. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  49869. /**
  49870. * When connection point is an uniform, this function will send its value to the effect
  49871. * @param effect defines the effect to transmit value to
  49872. * @param world defines the world matrix
  49873. * @param worldView defines the worldxview matrix
  49874. * @param worldViewProjection defines the worldxviewxprojection matrix
  49875. */
  49876. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  49877. /**
  49878. * When connection point is an uniform, this function will send its value to the effect
  49879. * @param effect defines the effect to transmit value to
  49880. * @param scene defines the hosting scene
  49881. */
  49882. transmit(effect: Effect, scene: Scene): void;
  49883. }
  49884. }
  49885. declare module BABYLON {
  49886. /**
  49887. * Block used to output the vertex position
  49888. */
  49889. export class VertexOutputBlock extends NodeMaterialBlock {
  49890. /**
  49891. * Creates a new VertexOutputBlock
  49892. * @param name defines the block name
  49893. */
  49894. constructor(name: string);
  49895. /**
  49896. * Gets the current class name
  49897. * @returns the class name
  49898. */
  49899. getClassName(): string;
  49900. /**
  49901. * Gets the vector input component
  49902. */
  49903. readonly vector: NodeMaterialConnectionPoint;
  49904. protected _buildBlock(state: NodeMaterialBuildState): this;
  49905. }
  49906. }
  49907. declare module BABYLON {
  49908. /**
  49909. * Block used to add support for vertex skinning (bones)
  49910. */
  49911. export class BonesBlock extends NodeMaterialBlock {
  49912. /**
  49913. * Creates a new BonesBlock
  49914. * @param name defines the block name
  49915. */
  49916. constructor(name: string);
  49917. /**
  49918. * Initialize the block and prepare the context for build
  49919. * @param state defines the state that will be used for the build
  49920. */
  49921. initialize(state: NodeMaterialBuildState): void;
  49922. /**
  49923. * Gets the current class name
  49924. * @returns the class name
  49925. */
  49926. getClassName(): string;
  49927. /**
  49928. * Gets the matrix indices input component
  49929. */
  49930. readonly matricesIndices: NodeMaterialConnectionPoint;
  49931. /**
  49932. * Gets the matrix weights input component
  49933. */
  49934. readonly matricesWeights: NodeMaterialConnectionPoint;
  49935. /**
  49936. * Gets the extra matrix indices input component
  49937. */
  49938. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  49939. /**
  49940. * Gets the extra matrix weights input component
  49941. */
  49942. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  49943. /**
  49944. * Gets the world input component
  49945. */
  49946. readonly world: NodeMaterialConnectionPoint;
  49947. autoConfigure(): void;
  49948. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  49949. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  49950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  49951. protected _buildBlock(state: NodeMaterialBuildState): this;
  49952. }
  49953. }
  49954. declare module BABYLON {
  49955. /**
  49956. * Block used to add support for instances
  49957. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  49958. */
  49959. export class InstancesBlock extends NodeMaterialBlock {
  49960. /**
  49961. * Creates a new InstancesBlock
  49962. * @param name defines the block name
  49963. */
  49964. constructor(name: string);
  49965. /**
  49966. * Gets the current class name
  49967. * @returns the class name
  49968. */
  49969. getClassName(): string;
  49970. /**
  49971. * Gets the first world row input component
  49972. */
  49973. readonly world0: NodeMaterialConnectionPoint;
  49974. /**
  49975. * Gets the second world row input component
  49976. */
  49977. readonly world1: NodeMaterialConnectionPoint;
  49978. /**
  49979. * Gets the third world row input component
  49980. */
  49981. readonly world2: NodeMaterialConnectionPoint;
  49982. /**
  49983. * Gets the forth world row input component
  49984. */
  49985. readonly world3: NodeMaterialConnectionPoint;
  49986. /**
  49987. * Gets the world input component
  49988. */
  49989. readonly world: NodeMaterialConnectionPoint;
  49990. /**
  49991. * Gets the output component
  49992. */
  49993. readonly output: NodeMaterialConnectionPoint;
  49994. autoConfigure(): void;
  49995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  49996. protected _buildBlock(state: NodeMaterialBuildState): this;
  49997. }
  49998. }
  49999. declare module BABYLON {
  50000. /**
  50001. * Block used to add morph targets support to vertex shader
  50002. */
  50003. export class MorphTargetsBlock extends NodeMaterialBlock {
  50004. private _repeatableContentAnchor;
  50005. private _repeatebleContentGenerated;
  50006. /**
  50007. * Create a new MorphTargetsBlock
  50008. * @param name defines the block name
  50009. */
  50010. constructor(name: string);
  50011. /**
  50012. * Gets the current class name
  50013. * @returns the class name
  50014. */
  50015. getClassName(): string;
  50016. /**
  50017. * Gets the position input component
  50018. */
  50019. readonly position: NodeMaterialConnectionPoint;
  50020. /**
  50021. * Gets the normal input component
  50022. */
  50023. readonly normal: NodeMaterialConnectionPoint;
  50024. /**
  50025. * Gets the tangent input component
  50026. */
  50027. readonly tangent: NodeMaterialConnectionPoint;
  50028. /**
  50029. * Gets the position output component
  50030. */
  50031. readonly positionOutput: NodeMaterialConnectionPoint;
  50032. /**
  50033. * Gets the normal output component
  50034. */
  50035. readonly normalOutput: NodeMaterialConnectionPoint;
  50036. /**
  50037. * Gets the tangent output component
  50038. */
  50039. readonly tangentOutput: NodeMaterialConnectionPoint;
  50040. initialize(state: NodeMaterialBuildState): void;
  50041. autoConfigure(): void;
  50042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50043. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50044. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50045. protected _buildBlock(state: NodeMaterialBuildState): this;
  50046. }
  50047. }
  50048. declare module BABYLON {
  50049. /**
  50050. * Block used to output the final color
  50051. */
  50052. export class FragmentOutputBlock extends NodeMaterialBlock {
  50053. /**
  50054. * Gets or sets a boolean indicating if this block will output an alpha value
  50055. */
  50056. alphaBlendingEnabled: boolean;
  50057. /**
  50058. * Create a new FragmentOutputBlock
  50059. * @param name defines the block name
  50060. */
  50061. constructor(name: string);
  50062. /**
  50063. * Gets the current class name
  50064. * @returns the class name
  50065. */
  50066. getClassName(): string;
  50067. /**
  50068. * Gets the color input component
  50069. */
  50070. readonly color: NodeMaterialConnectionPoint;
  50071. protected _buildBlock(state: NodeMaterialBuildState): this;
  50072. }
  50073. }
  50074. declare module BABYLON {
  50075. /**
  50076. * Block used to add an alpha test in the fragment shader
  50077. */
  50078. export class AlphaTestBlock extends NodeMaterialBlock {
  50079. /**
  50080. * Gets or sets the alpha value where alpha testing happens
  50081. */
  50082. alphaCutOff: number;
  50083. /**
  50084. * Create a new AlphaTestBlock
  50085. * @param name defines the block name
  50086. */
  50087. constructor(name: string);
  50088. /**
  50089. * Gets the current class name
  50090. * @returns the class name
  50091. */
  50092. getClassName(): string;
  50093. /**
  50094. * Gets the color input component
  50095. */
  50096. readonly color: NodeMaterialConnectionPoint;
  50097. protected _buildBlock(state: NodeMaterialBuildState): this;
  50098. }
  50099. }
  50100. declare module BABYLON {
  50101. /**
  50102. * Block used to create a Color4 out of 4 inputs (one for each component)
  50103. */
  50104. export class RGBAMergerBlock extends NodeMaterialBlock {
  50105. /**
  50106. * Create a new RGBAMergerBlock
  50107. * @param name defines the block name
  50108. */
  50109. constructor(name: string);
  50110. /**
  50111. * Gets the current class name
  50112. * @returns the class name
  50113. */
  50114. getClassName(): string;
  50115. /**
  50116. * Gets the R input component
  50117. */
  50118. readonly r: NodeMaterialConnectionPoint;
  50119. /**
  50120. * Gets the G input component
  50121. */
  50122. readonly g: NodeMaterialConnectionPoint;
  50123. /**
  50124. * Gets the B input component
  50125. */
  50126. readonly b: NodeMaterialConnectionPoint;
  50127. /**
  50128. * Gets the RGB input component
  50129. */
  50130. readonly rgb: NodeMaterialConnectionPoint;
  50131. /**
  50132. * Gets the R input component
  50133. */
  50134. readonly a: NodeMaterialConnectionPoint;
  50135. protected _buildBlock(state: NodeMaterialBuildState): this;
  50136. }
  50137. }
  50138. declare module BABYLON {
  50139. /**
  50140. * Block used to create a Color3 out of 3 inputs (one for each component)
  50141. */
  50142. export class RGBMergerBlock extends NodeMaterialBlock {
  50143. /**
  50144. * Create a new RGBMergerBlock
  50145. * @param name defines the block name
  50146. */
  50147. constructor(name: string);
  50148. /**
  50149. * Gets the current class name
  50150. * @returns the class name
  50151. */
  50152. getClassName(): string;
  50153. /**
  50154. * Gets the R component input
  50155. */
  50156. readonly r: NodeMaterialConnectionPoint;
  50157. /**
  50158. * Gets the G component input
  50159. */
  50160. readonly g: NodeMaterialConnectionPoint;
  50161. /**
  50162. * Gets the B component input
  50163. */
  50164. readonly b: NodeMaterialConnectionPoint;
  50165. protected _buildBlock(state: NodeMaterialBuildState): this;
  50166. }
  50167. }
  50168. declare module BABYLON {
  50169. /**
  50170. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  50171. */
  50172. export class RGBASplitterBlock extends NodeMaterialBlock {
  50173. /**
  50174. * Create a new RGBASplitterBlock
  50175. * @param name defines the block name
  50176. */
  50177. constructor(name: string);
  50178. /**
  50179. * Gets the current class name
  50180. * @returns the class name
  50181. */
  50182. getClassName(): string;
  50183. /**
  50184. * Gets the input component
  50185. */
  50186. readonly input: NodeMaterialConnectionPoint;
  50187. protected _buildBlock(state: NodeMaterialBuildState): this;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  50193. */
  50194. export class RGBSplitterBlock extends NodeMaterialBlock {
  50195. /**
  50196. * Create a new RGBSplitterBlock
  50197. * @param name defines the block name
  50198. */
  50199. constructor(name: string);
  50200. /**
  50201. * Gets the current class name
  50202. * @returns the class name
  50203. */
  50204. getClassName(): string;
  50205. /**
  50206. * Gets the input component
  50207. */
  50208. readonly input: NodeMaterialConnectionPoint;
  50209. protected _buildBlock(state: NodeMaterialBuildState): this;
  50210. }
  50211. }
  50212. declare module BABYLON {
  50213. /**
  50214. * Block used to read a texture from a sampler
  50215. */
  50216. export class TextureBlock extends NodeMaterialBlock {
  50217. private _defineName;
  50218. /**
  50219. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  50220. */
  50221. autoConnectTextureMatrix: boolean;
  50222. /**
  50223. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  50224. */
  50225. autoSelectUV: boolean;
  50226. /**
  50227. * Create a new TextureBlock
  50228. * @param name defines the block name
  50229. */
  50230. constructor(name: string);
  50231. /**
  50232. * Gets the current class name
  50233. * @returns the class name
  50234. */
  50235. getClassName(): string;
  50236. /**
  50237. * Gets the uv input component
  50238. */
  50239. readonly uv: NodeMaterialConnectionPoint;
  50240. /**
  50241. * Gets the texture information input component
  50242. */
  50243. readonly textureInfo: NodeMaterialConnectionPoint;
  50244. /**
  50245. * Gets the transformed uv input component
  50246. */
  50247. readonly transformedUV: NodeMaterialConnectionPoint;
  50248. /**
  50249. * Gets the texture input component
  50250. */
  50251. readonly texture: NodeMaterialConnectionPoint;
  50252. /**
  50253. * Gets the texture transform input component
  50254. */
  50255. readonly textureTransform: NodeMaterialConnectionPoint;
  50256. autoConfigure(): void;
  50257. initialize(state: NodeMaterialBuildState): void;
  50258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50259. isReady(): boolean;
  50260. private _injectVertexCode;
  50261. protected _buildBlock(state: NodeMaterialBuildState): this;
  50262. }
  50263. }
  50264. declare module BABYLON {
  50265. /**
  50266. * Block used to add image processing support to fragment shader
  50267. */
  50268. export class ImageProcessingBlock extends NodeMaterialBlock {
  50269. /**
  50270. * Create a new ImageProcessingBlock
  50271. * @param name defines the block name
  50272. */
  50273. constructor(name: string);
  50274. /**
  50275. * Gets the current class name
  50276. * @returns the class name
  50277. */
  50278. getClassName(): string;
  50279. /**
  50280. * Gets the color input component
  50281. */
  50282. readonly color: NodeMaterialConnectionPoint;
  50283. /**
  50284. * Initialize the block and prepare the context for build
  50285. * @param state defines the state that will be used for the build
  50286. */
  50287. initialize(state: NodeMaterialBuildState): void;
  50288. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  50289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50290. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50291. protected _buildBlock(state: NodeMaterialBuildState): this;
  50292. }
  50293. }
  50294. declare module BABYLON {
  50295. /**
  50296. * Block used to add support for scene fog
  50297. */
  50298. export class FogBlock extends NodeMaterialBlock {
  50299. /**
  50300. * Create a new FogBlock
  50301. * @param name defines the block name
  50302. */
  50303. constructor(name: string);
  50304. /**
  50305. * Gets the current class name
  50306. * @returns the class name
  50307. */
  50308. getClassName(): string;
  50309. /**
  50310. * Gets the world position input component
  50311. */
  50312. readonly worldPosition: NodeMaterialConnectionPoint;
  50313. /**
  50314. * Gets the view input component
  50315. */
  50316. readonly view: NodeMaterialConnectionPoint;
  50317. /**
  50318. * Gets the color input component
  50319. */
  50320. readonly color: NodeMaterialConnectionPoint;
  50321. /**
  50322. * Gets the fog color input component
  50323. */
  50324. readonly fogColor: NodeMaterialConnectionPoint;
  50325. /**
  50326. * Gets the for parameter input component
  50327. */
  50328. readonly fogParameters: NodeMaterialConnectionPoint;
  50329. autoConfigure(): void;
  50330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50331. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50332. protected _buildBlock(state: NodeMaterialBuildState): this;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. /**
  50337. * Block used to multiply 2 vector4
  50338. */
  50339. export class MultiplyBlock extends NodeMaterialBlock {
  50340. /**
  50341. * Creates a new MultiplyBlock
  50342. * @param name defines the block name
  50343. */
  50344. constructor(name: string);
  50345. /**
  50346. * Gets the current class name
  50347. * @returns the class name
  50348. */
  50349. getClassName(): string;
  50350. /**
  50351. * Gets the left operand input component
  50352. */
  50353. readonly left: NodeMaterialConnectionPoint;
  50354. /**
  50355. * Gets the right operand input component
  50356. */
  50357. readonly right: NodeMaterialConnectionPoint;
  50358. protected _buildBlock(state: NodeMaterialBuildState): this;
  50359. }
  50360. }
  50361. declare module BABYLON {
  50362. /**
  50363. * Block used to add 2 vector4
  50364. */
  50365. export class AddBlock extends NodeMaterialBlock {
  50366. /**
  50367. * Creates a new AddBlock
  50368. * @param name defines the block name
  50369. */
  50370. constructor(name: string);
  50371. /**
  50372. * Gets the current class name
  50373. * @returns the class name
  50374. */
  50375. getClassName(): string;
  50376. /**
  50377. * Gets the left operand input component
  50378. */
  50379. readonly left: NodeMaterialConnectionPoint;
  50380. /**
  50381. * Gets the right operand input component
  50382. */
  50383. readonly right: NodeMaterialConnectionPoint;
  50384. protected _buildBlock(state: NodeMaterialBuildState): this;
  50385. }
  50386. }
  50387. declare module BABYLON {
  50388. /**
  50389. * Block used to clamp a float
  50390. */
  50391. export class ClampBlock extends NodeMaterialBlock {
  50392. /** Gets or sets the minimum range */
  50393. minimum: number;
  50394. /** Gets or sets the maximum range */
  50395. maximum: number;
  50396. /**
  50397. * Creates a new ClampBlock
  50398. * @param name defines the block name
  50399. */
  50400. constructor(name: string);
  50401. /**
  50402. * Gets the current class name
  50403. * @returns the class name
  50404. */
  50405. getClassName(): string;
  50406. /**
  50407. * Gets the value input component
  50408. */
  50409. readonly value: NodeMaterialConnectionPoint;
  50410. protected _buildBlock(state: NodeMaterialBuildState): this;
  50411. }
  50412. }
  50413. declare module BABYLON {
  50414. /**
  50415. * Block used to transform a vector2 with a matrix
  50416. */
  50417. export class Vector2TransformBlock extends NodeMaterialBlock {
  50418. /**
  50419. * Defines the value to use to complement Vector2 to transform it to a Vector4
  50420. */
  50421. complementZ: number;
  50422. /**
  50423. * Defines the value to use to complement Vector2 to transform it to a Vector4
  50424. */
  50425. complementW: number;
  50426. /**
  50427. * Creates a new Vector2TransformBlock
  50428. * @param name defines the block name
  50429. */
  50430. constructor(name: string);
  50431. /**
  50432. * Gets the vector input
  50433. */
  50434. readonly vector: NodeMaterialConnectionPoint;
  50435. /**
  50436. * Gets the matrix transform input
  50437. */
  50438. readonly transform: NodeMaterialConnectionPoint;
  50439. /**
  50440. * Gets the current class name
  50441. * @returns the class name
  50442. */
  50443. getClassName(): string;
  50444. protected _buildBlock(state: NodeMaterialBuildState): this;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /**
  50449. * Block used to transform a vector3 with a matrix
  50450. */
  50451. export class Vector3TransformBlock extends NodeMaterialBlock {
  50452. /**
  50453. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50454. */
  50455. complement: number;
  50456. /**
  50457. * Creates a new Vector3TransformBlock
  50458. * @param name defines the block name
  50459. */
  50460. constructor(name: string);
  50461. /**
  50462. * Gets the vector input
  50463. */
  50464. readonly vector: NodeMaterialConnectionPoint;
  50465. /**
  50466. * Gets the matrix transform input
  50467. */
  50468. readonly transform: NodeMaterialConnectionPoint;
  50469. /**
  50470. * Gets the current class name
  50471. * @returns the class name
  50472. */
  50473. getClassName(): string;
  50474. protected _buildBlock(state: NodeMaterialBuildState): this;
  50475. }
  50476. }
  50477. declare module BABYLON {
  50478. /**
  50479. * Block used to transform a vector4 with a matrix
  50480. */
  50481. export class Vector4TransformBlock extends NodeMaterialBlock {
  50482. /**
  50483. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50484. */
  50485. complementW: number;
  50486. /**
  50487. * Creates a new Vector4TransformBlock
  50488. * @param name defines the block name
  50489. */
  50490. constructor(name: string);
  50491. /**
  50492. * Gets the current class name
  50493. * @returns the class name
  50494. */
  50495. getClassName(): string;
  50496. /**
  50497. * Gets the vector input
  50498. */
  50499. readonly vector: NodeMaterialConnectionPoint;
  50500. /**
  50501. * Gets the matrix transform input
  50502. */
  50503. readonly transform: NodeMaterialConnectionPoint;
  50504. protected _buildBlock(state: NodeMaterialBuildState): this;
  50505. }
  50506. }
  50507. declare module BABYLON {
  50508. /**
  50509. * Block used to multiply two matrices
  50510. */
  50511. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  50512. /**
  50513. * Creates a new MatrixMultiplicationBlock
  50514. * @param name defines the block name
  50515. */
  50516. constructor(name: string);
  50517. /**
  50518. * Gets the left operand
  50519. */
  50520. readonly left: NodeMaterialConnectionPoint;
  50521. /**
  50522. * Gets the right operand
  50523. */
  50524. readonly right: NodeMaterialConnectionPoint;
  50525. /**
  50526. * Gets the current class name
  50527. * @returns the class name
  50528. */
  50529. getClassName(): string;
  50530. protected _buildBlock(state: NodeMaterialBuildState): this;
  50531. }
  50532. }
  50533. declare module BABYLON {
  50534. /**
  50535. * Helper class to push actions to a pool of workers.
  50536. */
  50537. export class WorkerPool implements IDisposable {
  50538. private _workerInfos;
  50539. private _pendingActions;
  50540. /**
  50541. * Constructor
  50542. * @param workers Array of workers to use for actions
  50543. */
  50544. constructor(workers: Array<Worker>);
  50545. /**
  50546. * Terminates all workers and clears any pending actions.
  50547. */
  50548. dispose(): void;
  50549. /**
  50550. * Pushes an action to the worker pool. If all the workers are active, the action will be
  50551. * pended until a worker has completed its action.
  50552. * @param action The action to perform. Call onComplete when the action is complete.
  50553. */
  50554. push(action: (worker: Worker, onComplete: () => void) => void): void;
  50555. private _execute;
  50556. }
  50557. }
  50558. declare module BABYLON {
  50559. /**
  50560. * Configuration for Draco compression
  50561. */
  50562. export interface IDracoCompressionConfiguration {
  50563. /**
  50564. * Configuration for the decoder.
  50565. */
  50566. decoder: {
  50567. /**
  50568. * The url to the WebAssembly module.
  50569. */
  50570. wasmUrl?: string;
  50571. /**
  50572. * The url to the WebAssembly binary.
  50573. */
  50574. wasmBinaryUrl?: string;
  50575. /**
  50576. * The url to the fallback JavaScript module.
  50577. */
  50578. fallbackUrl?: string;
  50579. };
  50580. }
  50581. /**
  50582. * Draco compression (https://google.github.io/draco/)
  50583. *
  50584. * This class wraps the Draco module.
  50585. *
  50586. * **Encoder**
  50587. *
  50588. * The encoder is not currently implemented.
  50589. *
  50590. * **Decoder**
  50591. *
  50592. * 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.
  50593. *
  50594. * To update the configuration, use the following code:
  50595. * ```javascript
  50596. * DracoCompression.Configuration = {
  50597. * decoder: {
  50598. * wasmUrl: "<url to the WebAssembly library>",
  50599. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50600. * fallbackUrl: "<url to the fallback JavaScript library>",
  50601. * }
  50602. * };
  50603. * ```
  50604. *
  50605. * 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.
  50606. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50607. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  50608. *
  50609. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  50610. * ```javascript
  50611. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  50612. * ```
  50613. *
  50614. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50615. */
  50616. export class DracoCompression implements IDisposable {
  50617. private _workerPoolPromise?;
  50618. private _decoderModulePromise?;
  50619. /**
  50620. * The configuration. Defaults to the following urls:
  50621. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50622. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50623. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50624. */
  50625. static Configuration: IDracoCompressionConfiguration;
  50626. /**
  50627. * Returns true if the decoder configuration is available.
  50628. */
  50629. static readonly DecoderAvailable: boolean;
  50630. /**
  50631. * Default number of workers to create when creating the draco compression object.
  50632. */
  50633. static DefaultNumWorkers: number;
  50634. private static GetDefaultNumWorkers;
  50635. private static _Default;
  50636. /**
  50637. * Default instance for the draco compression object.
  50638. */
  50639. static readonly Default: DracoCompression;
  50640. /**
  50641. * Constructor
  50642. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  50643. */
  50644. constructor(numWorkers?: number);
  50645. /**
  50646. * Stop all async operations and release resources.
  50647. */
  50648. dispose(): void;
  50649. /**
  50650. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  50651. * @returns a promise that resolves when ready
  50652. */
  50653. whenReadyAsync(): Promise<void>;
  50654. /**
  50655. * Decode Draco compressed mesh data to vertex data.
  50656. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50657. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50658. * @returns A promise that resolves with the decoded vertex data
  50659. */
  50660. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  50661. [kind: string]: number;
  50662. }): Promise<VertexData>;
  50663. }
  50664. }
  50665. declare module BABYLON {
  50666. /**
  50667. * Class for building Constructive Solid Geometry
  50668. */
  50669. export class CSG {
  50670. private polygons;
  50671. /**
  50672. * The world matrix
  50673. */
  50674. matrix: Matrix;
  50675. /**
  50676. * Stores the position
  50677. */
  50678. position: Vector3;
  50679. /**
  50680. * Stores the rotation
  50681. */
  50682. rotation: Vector3;
  50683. /**
  50684. * Stores the rotation quaternion
  50685. */
  50686. rotationQuaternion: Nullable<Quaternion>;
  50687. /**
  50688. * Stores the scaling vector
  50689. */
  50690. scaling: Vector3;
  50691. /**
  50692. * Convert the Mesh to CSG
  50693. * @param mesh The Mesh to convert to CSG
  50694. * @returns A new CSG from the Mesh
  50695. */
  50696. static FromMesh(mesh: Mesh): CSG;
  50697. /**
  50698. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50699. * @param polygons Polygons used to construct a CSG solid
  50700. */
  50701. private static FromPolygons;
  50702. /**
  50703. * Clones, or makes a deep copy, of the CSG
  50704. * @returns A new CSG
  50705. */
  50706. clone(): CSG;
  50707. /**
  50708. * Unions this CSG with another CSG
  50709. * @param csg The CSG to union against this CSG
  50710. * @returns The unioned CSG
  50711. */
  50712. union(csg: CSG): CSG;
  50713. /**
  50714. * Unions this CSG with another CSG in place
  50715. * @param csg The CSG to union against this CSG
  50716. */
  50717. unionInPlace(csg: CSG): void;
  50718. /**
  50719. * Subtracts this CSG with another CSG
  50720. * @param csg The CSG to subtract against this CSG
  50721. * @returns A new CSG
  50722. */
  50723. subtract(csg: CSG): CSG;
  50724. /**
  50725. * Subtracts this CSG with another CSG in place
  50726. * @param csg The CSG to subtact against this CSG
  50727. */
  50728. subtractInPlace(csg: CSG): void;
  50729. /**
  50730. * Intersect this CSG with another CSG
  50731. * @param csg The CSG to intersect against this CSG
  50732. * @returns A new CSG
  50733. */
  50734. intersect(csg: CSG): CSG;
  50735. /**
  50736. * Intersects this CSG with another CSG in place
  50737. * @param csg The CSG to intersect against this CSG
  50738. */
  50739. intersectInPlace(csg: CSG): void;
  50740. /**
  50741. * Return a new CSG solid with solid and empty space switched. This solid is
  50742. * not modified.
  50743. * @returns A new CSG solid with solid and empty space switched
  50744. */
  50745. inverse(): CSG;
  50746. /**
  50747. * Inverses the CSG in place
  50748. */
  50749. inverseInPlace(): void;
  50750. /**
  50751. * This is used to keep meshes transformations so they can be restored
  50752. * when we build back a Babylon Mesh
  50753. * NB : All CSG operations are performed in world coordinates
  50754. * @param csg The CSG to copy the transform attributes from
  50755. * @returns This CSG
  50756. */
  50757. copyTransformAttributes(csg: CSG): CSG;
  50758. /**
  50759. * Build Raw mesh from CSG
  50760. * Coordinates here are in world space
  50761. * @param name The name of the mesh geometry
  50762. * @param scene The Scene
  50763. * @param keepSubMeshes Specifies if the submeshes should be kept
  50764. * @returns A new Mesh
  50765. */
  50766. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50767. /**
  50768. * Build Mesh from CSG taking material and transforms into account
  50769. * @param name The name of the Mesh
  50770. * @param material The material of the Mesh
  50771. * @param scene The Scene
  50772. * @param keepSubMeshes Specifies if submeshes should be kept
  50773. * @returns The new Mesh
  50774. */
  50775. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50776. }
  50777. }
  50778. declare module BABYLON {
  50779. /**
  50780. * Class used to create a trail following a mesh
  50781. */
  50782. export class TrailMesh extends Mesh {
  50783. private _generator;
  50784. private _autoStart;
  50785. private _running;
  50786. private _diameter;
  50787. private _length;
  50788. private _sectionPolygonPointsCount;
  50789. private _sectionVectors;
  50790. private _sectionNormalVectors;
  50791. private _beforeRenderObserver;
  50792. /**
  50793. * @constructor
  50794. * @param name The value used by scene.getMeshByName() to do a lookup.
  50795. * @param generator The mesh to generate a trail.
  50796. * @param scene The scene to add this mesh to.
  50797. * @param diameter Diameter of trailing mesh. Default is 1.
  50798. * @param length Length of trailing mesh. Default is 60.
  50799. * @param autoStart Automatically start trailing mesh. Default true.
  50800. */
  50801. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50802. /**
  50803. * "TrailMesh"
  50804. * @returns "TrailMesh"
  50805. */
  50806. getClassName(): string;
  50807. private _createMesh;
  50808. /**
  50809. * Start trailing mesh.
  50810. */
  50811. start(): void;
  50812. /**
  50813. * Stop trailing mesh.
  50814. */
  50815. stop(): void;
  50816. /**
  50817. * Update trailing mesh geometry.
  50818. */
  50819. update(): void;
  50820. /**
  50821. * Returns a new TrailMesh object.
  50822. * @param name is a string, the name given to the new mesh
  50823. * @param newGenerator use new generator object for cloned trail mesh
  50824. * @returns a new mesh
  50825. */
  50826. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50827. /**
  50828. * Serializes this trail mesh
  50829. * @param serializationObject object to write serialization to
  50830. */
  50831. serialize(serializationObject: any): void;
  50832. /**
  50833. * Parses a serialized trail mesh
  50834. * @param parsedMesh the serialized mesh
  50835. * @param scene the scene to create the trail mesh in
  50836. * @returns the created trail mesh
  50837. */
  50838. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50839. }
  50840. }
  50841. declare module BABYLON {
  50842. /**
  50843. * Class containing static functions to help procedurally build meshes
  50844. */
  50845. export class TiledBoxBuilder {
  50846. /**
  50847. * Creates a box mesh
  50848. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  50849. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50851. * * 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
  50852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50853. * @param name defines the name of the mesh
  50854. * @param options defines the options used to create the mesh
  50855. * @param scene defines the hosting scene
  50856. * @returns the box mesh
  50857. */
  50858. static CreateTiledBox(name: string, options: {
  50859. pattern?: number;
  50860. width?: number;
  50861. height?: number;
  50862. depth?: number;
  50863. tileSize?: number;
  50864. tileWidth?: number;
  50865. tileHeight?: number;
  50866. alignHorizontal?: number;
  50867. alignVertical?: number;
  50868. faceUV?: Vector4[];
  50869. faceColors?: Color4[];
  50870. sideOrientation?: number;
  50871. updatable?: boolean;
  50872. }, scene?: Nullable<Scene>): Mesh;
  50873. }
  50874. }
  50875. declare module BABYLON {
  50876. /**
  50877. * Class containing static functions to help procedurally build meshes
  50878. */
  50879. export class TorusKnotBuilder {
  50880. /**
  50881. * Creates a torus knot mesh
  50882. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50883. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50884. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50885. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50887. * * 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
  50888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50889. * @param name defines the name of the mesh
  50890. * @param options defines the options used to create the mesh
  50891. * @param scene defines the hosting scene
  50892. * @returns the torus knot mesh
  50893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50894. */
  50895. static CreateTorusKnot(name: string, options: {
  50896. radius?: number;
  50897. tube?: number;
  50898. radialSegments?: number;
  50899. tubularSegments?: number;
  50900. p?: number;
  50901. q?: number;
  50902. updatable?: boolean;
  50903. sideOrientation?: number;
  50904. frontUVs?: Vector4;
  50905. backUVs?: Vector4;
  50906. }, scene: any): Mesh;
  50907. }
  50908. }
  50909. declare module BABYLON {
  50910. /**
  50911. * Polygon
  50912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50913. */
  50914. export class Polygon {
  50915. /**
  50916. * Creates a rectangle
  50917. * @param xmin bottom X coord
  50918. * @param ymin bottom Y coord
  50919. * @param xmax top X coord
  50920. * @param ymax top Y coord
  50921. * @returns points that make the resulting rectation
  50922. */
  50923. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50924. /**
  50925. * Creates a circle
  50926. * @param radius radius of circle
  50927. * @param cx scale in x
  50928. * @param cy scale in y
  50929. * @param numberOfSides number of sides that make up the circle
  50930. * @returns points that make the resulting circle
  50931. */
  50932. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50933. /**
  50934. * Creates a polygon from input string
  50935. * @param input Input polygon data
  50936. * @returns the parsed points
  50937. */
  50938. static Parse(input: string): Vector2[];
  50939. /**
  50940. * Starts building a polygon from x and y coordinates
  50941. * @param x x coordinate
  50942. * @param y y coordinate
  50943. * @returns the started path2
  50944. */
  50945. static StartingAt(x: number, y: number): Path2;
  50946. }
  50947. /**
  50948. * Builds a polygon
  50949. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50950. */
  50951. export class PolygonMeshBuilder {
  50952. private _points;
  50953. private _outlinepoints;
  50954. private _holes;
  50955. private _name;
  50956. private _scene;
  50957. private _epoints;
  50958. private _eholes;
  50959. private _addToepoint;
  50960. /**
  50961. * Babylon reference to the earcut plugin.
  50962. */
  50963. bjsEarcut: any;
  50964. /**
  50965. * Creates a PolygonMeshBuilder
  50966. * @param name name of the builder
  50967. * @param contours Path of the polygon
  50968. * @param scene scene to add to when creating the mesh
  50969. * @param earcutInjection can be used to inject your own earcut reference
  50970. */
  50971. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50972. /**
  50973. * Adds a whole within the polygon
  50974. * @param hole Array of points defining the hole
  50975. * @returns this
  50976. */
  50977. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50978. /**
  50979. * Creates the polygon
  50980. * @param updatable If the mesh should be updatable
  50981. * @param depth The depth of the mesh created
  50982. * @returns the created mesh
  50983. */
  50984. build(updatable?: boolean, depth?: number): Mesh;
  50985. /**
  50986. * Creates the polygon
  50987. * @param depth The depth of the mesh created
  50988. * @returns the created VertexData
  50989. */
  50990. buildVertexData(depth?: number): VertexData;
  50991. /**
  50992. * Adds a side to the polygon
  50993. * @param positions points that make the polygon
  50994. * @param normals normals of the polygon
  50995. * @param uvs uvs of the polygon
  50996. * @param indices indices of the polygon
  50997. * @param bounds bounds of the polygon
  50998. * @param points points of the polygon
  50999. * @param depth depth of the polygon
  51000. * @param flip flip of the polygon
  51001. */
  51002. private addSide;
  51003. }
  51004. }
  51005. declare module BABYLON {
  51006. /**
  51007. * Class containing static functions to help procedurally build meshes
  51008. */
  51009. export class PolygonBuilder {
  51010. /**
  51011. * Creates a polygon mesh
  51012. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51013. * * 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
  51014. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51016. * * 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)
  51017. * * Remember you can only change the shape positions, not their number when updating a polygon
  51018. * @param name defines the name of the mesh
  51019. * @param options defines the options used to create the mesh
  51020. * @param scene defines the hosting scene
  51021. * @param earcutInjection can be used to inject your own earcut reference
  51022. * @returns the polygon mesh
  51023. */
  51024. static CreatePolygon(name: string, options: {
  51025. shape: Vector3[];
  51026. holes?: Vector3[][];
  51027. depth?: number;
  51028. faceUV?: Vector4[];
  51029. faceColors?: Color4[];
  51030. updatable?: boolean;
  51031. sideOrientation?: number;
  51032. frontUVs?: Vector4;
  51033. backUVs?: Vector4;
  51034. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51035. /**
  51036. * Creates an extruded polygon mesh, with depth in the Y direction.
  51037. * * 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)
  51038. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51039. * @param name defines the name of the mesh
  51040. * @param options defines the options used to create the mesh
  51041. * @param scene defines the hosting scene
  51042. * @param earcutInjection can be used to inject your own earcut reference
  51043. * @returns the polygon mesh
  51044. */
  51045. static ExtrudePolygon(name: string, options: {
  51046. shape: Vector3[];
  51047. holes?: Vector3[][];
  51048. depth?: number;
  51049. faceUV?: Vector4[];
  51050. faceColors?: Color4[];
  51051. updatable?: boolean;
  51052. sideOrientation?: number;
  51053. frontUVs?: Vector4;
  51054. backUVs?: Vector4;
  51055. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51056. }
  51057. }
  51058. declare module BABYLON {
  51059. /**
  51060. * Class containing static functions to help procedurally build meshes
  51061. */
  51062. export class LatheBuilder {
  51063. /**
  51064. * Creates lathe mesh.
  51065. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51066. * * 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
  51067. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51068. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51069. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51070. * * 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
  51071. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51072. * * 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
  51073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51074. * * 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
  51075. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51077. * @param name defines the name of the mesh
  51078. * @param options defines the options used to create the mesh
  51079. * @param scene defines the hosting scene
  51080. * @returns the lathe mesh
  51081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51082. */
  51083. static CreateLathe(name: string, options: {
  51084. shape: Vector3[];
  51085. radius?: number;
  51086. tessellation?: number;
  51087. clip?: number;
  51088. arc?: number;
  51089. closed?: boolean;
  51090. updatable?: boolean;
  51091. sideOrientation?: number;
  51092. frontUVs?: Vector4;
  51093. backUVs?: Vector4;
  51094. cap?: number;
  51095. invertUV?: boolean;
  51096. }, scene?: Nullable<Scene>): Mesh;
  51097. }
  51098. }
  51099. declare module BABYLON {
  51100. /**
  51101. * Class containing static functions to help procedurally build meshes
  51102. */
  51103. export class TiledPlaneBuilder {
  51104. /**
  51105. * Creates a tiled plane mesh
  51106. * * The parameter `pattern` will, depending on value, do nothing or
  51107. * * * flip (reflect about central vertical) alternate tiles across and up
  51108. * * * flip every tile on alternate rows
  51109. * * * rotate (180 degs) alternate tiles across and up
  51110. * * * rotate every tile on alternate rows
  51111. * * * flip and rotate alternate tiles across and up
  51112. * * * flip and rotate every tile on alternate rows
  51113. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  51114. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  51115. * * 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
  51116. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51117. * * 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)
  51118. * * 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)
  51119. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51120. * @param name defines the name of the mesh
  51121. * @param options defines the options used to create the mesh
  51122. * @param scene defines the hosting scene
  51123. * @returns the box mesh
  51124. */
  51125. static CreateTiledPlane(name: string, options: {
  51126. pattern?: number;
  51127. tileSize?: number;
  51128. tileWidth?: number;
  51129. tileHeight?: number;
  51130. size?: number;
  51131. width?: number;
  51132. height?: number;
  51133. alignHorizontal?: number;
  51134. alignVertical?: number;
  51135. sideOrientation?: number;
  51136. frontUVs?: Vector4;
  51137. backUVs?: Vector4;
  51138. updatable?: boolean;
  51139. }, scene?: Nullable<Scene>): Mesh;
  51140. }
  51141. }
  51142. declare module BABYLON {
  51143. /**
  51144. * Class containing static functions to help procedurally build meshes
  51145. */
  51146. export class TubeBuilder {
  51147. /**
  51148. * Creates a tube mesh.
  51149. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51150. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51151. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51152. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51153. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51154. * * 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)
  51155. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51156. * * 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
  51157. * * 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
  51158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51159. * * 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
  51160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51162. * @param name defines the name of the mesh
  51163. * @param options defines the options used to create the mesh
  51164. * @param scene defines the hosting scene
  51165. * @returns the tube mesh
  51166. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51167. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51168. */
  51169. static CreateTube(name: string, options: {
  51170. path: Vector3[];
  51171. radius?: number;
  51172. tessellation?: number;
  51173. radiusFunction?: {
  51174. (i: number, distance: number): number;
  51175. };
  51176. cap?: number;
  51177. arc?: number;
  51178. updatable?: boolean;
  51179. sideOrientation?: number;
  51180. frontUVs?: Vector4;
  51181. backUVs?: Vector4;
  51182. instance?: Mesh;
  51183. invertUV?: boolean;
  51184. }, scene?: Nullable<Scene>): Mesh;
  51185. }
  51186. }
  51187. declare module BABYLON {
  51188. /**
  51189. * Class containing static functions to help procedurally build meshes
  51190. */
  51191. export class IcoSphereBuilder {
  51192. /**
  51193. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51194. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51195. * * 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`)
  51196. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51197. * * 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
  51198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51199. * * 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
  51200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51201. * @param name defines the name of the mesh
  51202. * @param options defines the options used to create the mesh
  51203. * @param scene defines the hosting scene
  51204. * @returns the icosahedron mesh
  51205. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51206. */
  51207. static CreateIcoSphere(name: string, options: {
  51208. radius?: number;
  51209. radiusX?: number;
  51210. radiusY?: number;
  51211. radiusZ?: number;
  51212. flat?: boolean;
  51213. subdivisions?: number;
  51214. sideOrientation?: number;
  51215. frontUVs?: Vector4;
  51216. backUVs?: Vector4;
  51217. updatable?: boolean;
  51218. }, scene?: Nullable<Scene>): Mesh;
  51219. }
  51220. }
  51221. declare module BABYLON {
  51222. /**
  51223. * Class containing static functions to help procedurally build meshes
  51224. */
  51225. export class DecalBuilder {
  51226. /**
  51227. * Creates a decal mesh.
  51228. * 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
  51229. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51230. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51231. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51232. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51233. * @param name defines the name of the mesh
  51234. * @param sourceMesh defines the mesh where the decal must be applied
  51235. * @param options defines the options used to create the mesh
  51236. * @param scene defines the hosting scene
  51237. * @returns the decal mesh
  51238. * @see https://doc.babylonjs.com/how_to/decals
  51239. */
  51240. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51241. position?: Vector3;
  51242. normal?: Vector3;
  51243. size?: Vector3;
  51244. angle?: number;
  51245. }): Mesh;
  51246. }
  51247. }
  51248. declare module BABYLON {
  51249. /**
  51250. * Class containing static functions to help procedurally build meshes
  51251. */
  51252. export class MeshBuilder {
  51253. /**
  51254. * Creates a box mesh
  51255. * * The parameter `size` sets the size (float) of each box side (default 1)
  51256. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51257. * * 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)
  51258. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51260. * * 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
  51261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51262. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51263. * @param name defines the name of the mesh
  51264. * @param options defines the options used to create the mesh
  51265. * @param scene defines the hosting scene
  51266. * @returns the box mesh
  51267. */
  51268. static CreateBox(name: string, options: {
  51269. size?: number;
  51270. width?: number;
  51271. height?: number;
  51272. depth?: number;
  51273. faceUV?: Vector4[];
  51274. faceColors?: Color4[];
  51275. sideOrientation?: number;
  51276. frontUVs?: Vector4;
  51277. backUVs?: Vector4;
  51278. updatable?: boolean;
  51279. }, scene?: Nullable<Scene>): Mesh;
  51280. /**
  51281. * Creates a tiled box mesh
  51282. * * faceTiles sets the pattern, tile size and number of tiles for a face
  51283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51284. * @param name defines the name of the mesh
  51285. * @param options defines the options used to create the mesh
  51286. * @param scene defines the hosting scene
  51287. * @returns the tiled box mesh
  51288. */
  51289. static CreateTiledBox(name: string, options: {
  51290. pattern?: number;
  51291. size?: number;
  51292. width?: number;
  51293. height?: number;
  51294. depth: number;
  51295. tileSize?: number;
  51296. tileWidth?: number;
  51297. tileHeight?: number;
  51298. faceUV?: Vector4[];
  51299. faceColors?: Color4[];
  51300. alignHorizontal?: number;
  51301. alignVertical?: number;
  51302. sideOrientation?: number;
  51303. updatable?: boolean;
  51304. }, scene?: Nullable<Scene>): Mesh;
  51305. /**
  51306. * Creates a sphere mesh
  51307. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51308. * * 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`)
  51309. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51310. * * 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
  51311. * * 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)
  51312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51313. * * 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
  51314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51315. * @param name defines the name of the mesh
  51316. * @param options defines the options used to create the mesh
  51317. * @param scene defines the hosting scene
  51318. * @returns the sphere mesh
  51319. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51320. */
  51321. static CreateSphere(name: string, options: {
  51322. segments?: number;
  51323. diameter?: number;
  51324. diameterX?: number;
  51325. diameterY?: number;
  51326. diameterZ?: number;
  51327. arc?: number;
  51328. slice?: number;
  51329. sideOrientation?: number;
  51330. frontUVs?: Vector4;
  51331. backUVs?: Vector4;
  51332. updatable?: boolean;
  51333. }, scene?: Nullable<Scene>): Mesh;
  51334. /**
  51335. * Creates a plane polygonal mesh. By default, this is a disc
  51336. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51337. * * 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
  51338. * * 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
  51339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51340. * * 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
  51341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51342. * @param name defines the name of the mesh
  51343. * @param options defines the options used to create the mesh
  51344. * @param scene defines the hosting scene
  51345. * @returns the plane polygonal mesh
  51346. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51347. */
  51348. static CreateDisc(name: string, options: {
  51349. radius?: number;
  51350. tessellation?: number;
  51351. arc?: number;
  51352. updatable?: boolean;
  51353. sideOrientation?: number;
  51354. frontUVs?: Vector4;
  51355. backUVs?: Vector4;
  51356. }, scene?: Nullable<Scene>): Mesh;
  51357. /**
  51358. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51359. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51360. * * 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`)
  51361. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51362. * * 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
  51363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51364. * * 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
  51365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51366. * @param name defines the name of the mesh
  51367. * @param options defines the options used to create the mesh
  51368. * @param scene defines the hosting scene
  51369. * @returns the icosahedron mesh
  51370. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51371. */
  51372. static CreateIcoSphere(name: string, options: {
  51373. radius?: number;
  51374. radiusX?: number;
  51375. radiusY?: number;
  51376. radiusZ?: number;
  51377. flat?: boolean;
  51378. subdivisions?: number;
  51379. sideOrientation?: number;
  51380. frontUVs?: Vector4;
  51381. backUVs?: Vector4;
  51382. updatable?: boolean;
  51383. }, scene?: Nullable<Scene>): Mesh;
  51384. /**
  51385. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51386. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51387. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51388. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51389. * * 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
  51390. * * 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
  51391. * * 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
  51392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51393. * * 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
  51394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51395. * * 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
  51396. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51397. * * 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
  51398. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51400. * @param name defines the name of the mesh
  51401. * @param options defines the options used to create the mesh
  51402. * @param scene defines the hosting scene
  51403. * @returns the ribbon mesh
  51404. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51406. */
  51407. static CreateRibbon(name: string, options: {
  51408. pathArray: Vector3[][];
  51409. closeArray?: boolean;
  51410. closePath?: boolean;
  51411. offset?: number;
  51412. updatable?: boolean;
  51413. sideOrientation?: number;
  51414. frontUVs?: Vector4;
  51415. backUVs?: Vector4;
  51416. instance?: Mesh;
  51417. invertUV?: boolean;
  51418. uvs?: Vector2[];
  51419. colors?: Color4[];
  51420. }, scene?: Nullable<Scene>): Mesh;
  51421. /**
  51422. * Creates a cylinder or a cone mesh
  51423. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51424. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51425. * * 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.
  51426. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51427. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51428. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51429. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51430. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  51431. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51432. * * 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).
  51433. * * 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
  51434. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51435. * * 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
  51436. * * 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.
  51437. * * If `enclose` is false, a ring surface is one element.
  51438. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51439. * * 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
  51440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51441. * * 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
  51442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51443. * @param name defines the name of the mesh
  51444. * @param options defines the options used to create the mesh
  51445. * @param scene defines the hosting scene
  51446. * @returns the cylinder mesh
  51447. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51448. */
  51449. static CreateCylinder(name: string, options: {
  51450. height?: number;
  51451. diameterTop?: number;
  51452. diameterBottom?: number;
  51453. diameter?: number;
  51454. tessellation?: number;
  51455. subdivisions?: number;
  51456. arc?: number;
  51457. faceColors?: Color4[];
  51458. faceUV?: Vector4[];
  51459. updatable?: boolean;
  51460. hasRings?: boolean;
  51461. enclose?: boolean;
  51462. cap?: number;
  51463. sideOrientation?: number;
  51464. frontUVs?: Vector4;
  51465. backUVs?: Vector4;
  51466. }, scene?: Nullable<Scene>): Mesh;
  51467. /**
  51468. * Creates a torus mesh
  51469. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51470. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51471. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51473. * * 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
  51474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51475. * @param name defines the name of the mesh
  51476. * @param options defines the options used to create the mesh
  51477. * @param scene defines the hosting scene
  51478. * @returns the torus mesh
  51479. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51480. */
  51481. static CreateTorus(name: string, options: {
  51482. diameter?: number;
  51483. thickness?: number;
  51484. tessellation?: number;
  51485. updatable?: boolean;
  51486. sideOrientation?: number;
  51487. frontUVs?: Vector4;
  51488. backUVs?: Vector4;
  51489. }, scene?: Nullable<Scene>): Mesh;
  51490. /**
  51491. * Creates a torus knot mesh
  51492. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51493. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51494. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51495. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51497. * * 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
  51498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51499. * @param name defines the name of the mesh
  51500. * @param options defines the options used to create the mesh
  51501. * @param scene defines the hosting scene
  51502. * @returns the torus knot mesh
  51503. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51504. */
  51505. static CreateTorusKnot(name: string, options: {
  51506. radius?: number;
  51507. tube?: number;
  51508. radialSegments?: number;
  51509. tubularSegments?: number;
  51510. p?: number;
  51511. q?: number;
  51512. updatable?: boolean;
  51513. sideOrientation?: number;
  51514. frontUVs?: Vector4;
  51515. backUVs?: Vector4;
  51516. }, scene?: Nullable<Scene>): Mesh;
  51517. /**
  51518. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51519. * * 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
  51520. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51521. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51522. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51523. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51524. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51525. * * 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
  51526. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51529. * @param name defines the name of the new line system
  51530. * @param options defines the options used to create the line system
  51531. * @param scene defines the hosting scene
  51532. * @returns a new line system mesh
  51533. */
  51534. static CreateLineSystem(name: string, options: {
  51535. lines: Vector3[][];
  51536. updatable?: boolean;
  51537. instance?: Nullable<LinesMesh>;
  51538. colors?: Nullable<Color4[][]>;
  51539. useVertexAlpha?: boolean;
  51540. }, scene: Nullable<Scene>): LinesMesh;
  51541. /**
  51542. * Creates a line mesh
  51543. * 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
  51544. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51545. * * The parameter `points` is an array successive Vector3
  51546. * * 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
  51547. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51548. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51549. * * When updating an instance, remember that only point positions can change, not the number of points
  51550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51552. * @param name defines the name of the new line system
  51553. * @param options defines the options used to create the line system
  51554. * @param scene defines the hosting scene
  51555. * @returns a new line mesh
  51556. */
  51557. static CreateLines(name: string, options: {
  51558. points: Vector3[];
  51559. updatable?: boolean;
  51560. instance?: Nullable<LinesMesh>;
  51561. colors?: Color4[];
  51562. useVertexAlpha?: boolean;
  51563. }, scene?: Nullable<Scene>): LinesMesh;
  51564. /**
  51565. * Creates a dashed line mesh
  51566. * * 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
  51567. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51568. * * The parameter `points` is an array successive Vector3
  51569. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51570. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51571. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51572. * * 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
  51573. * * When updating an instance, remember that only point positions can change, not the number of points
  51574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51575. * @param name defines the name of the mesh
  51576. * @param options defines the options used to create the mesh
  51577. * @param scene defines the hosting scene
  51578. * @returns the dashed line mesh
  51579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51580. */
  51581. static CreateDashedLines(name: string, options: {
  51582. points: Vector3[];
  51583. dashSize?: number;
  51584. gapSize?: number;
  51585. dashNb?: number;
  51586. updatable?: boolean;
  51587. instance?: LinesMesh;
  51588. }, scene?: Nullable<Scene>): LinesMesh;
  51589. /**
  51590. * 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.
  51591. * * 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.
  51592. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51593. * * 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.
  51594. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51595. * * 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
  51596. * * 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
  51597. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51599. * * 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
  51600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51602. * @param name defines the name of the mesh
  51603. * @param options defines the options used to create the mesh
  51604. * @param scene defines the hosting scene
  51605. * @returns the extruded shape mesh
  51606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51608. */
  51609. static ExtrudeShape(name: string, options: {
  51610. shape: Vector3[];
  51611. path: Vector3[];
  51612. scale?: number;
  51613. rotation?: number;
  51614. cap?: number;
  51615. updatable?: boolean;
  51616. sideOrientation?: number;
  51617. frontUVs?: Vector4;
  51618. backUVs?: Vector4;
  51619. instance?: Mesh;
  51620. invertUV?: boolean;
  51621. }, scene?: Nullable<Scene>): Mesh;
  51622. /**
  51623. * Creates an custom extruded shape mesh.
  51624. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51625. * * 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.
  51626. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51627. * * 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
  51628. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51629. * * 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
  51630. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51631. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51632. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51633. * * 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
  51634. * * 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
  51635. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51637. * * 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
  51638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51640. * @param name defines the name of the mesh
  51641. * @param options defines the options used to create the mesh
  51642. * @param scene defines the hosting scene
  51643. * @returns the custom extruded shape mesh
  51644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51647. */
  51648. static ExtrudeShapeCustom(name: string, options: {
  51649. shape: Vector3[];
  51650. path: Vector3[];
  51651. scaleFunction?: any;
  51652. rotationFunction?: any;
  51653. ribbonCloseArray?: boolean;
  51654. ribbonClosePath?: boolean;
  51655. cap?: number;
  51656. updatable?: boolean;
  51657. sideOrientation?: number;
  51658. frontUVs?: Vector4;
  51659. backUVs?: Vector4;
  51660. instance?: Mesh;
  51661. invertUV?: boolean;
  51662. }, scene?: Nullable<Scene>): Mesh;
  51663. /**
  51664. * Creates lathe mesh.
  51665. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51666. * * 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
  51667. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51668. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51669. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51670. * * 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
  51671. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51672. * * 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
  51673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51674. * * 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
  51675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51677. * @param name defines the name of the mesh
  51678. * @param options defines the options used to create the mesh
  51679. * @param scene defines the hosting scene
  51680. * @returns the lathe mesh
  51681. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51682. */
  51683. static CreateLathe(name: string, options: {
  51684. shape: Vector3[];
  51685. radius?: number;
  51686. tessellation?: number;
  51687. clip?: number;
  51688. arc?: number;
  51689. closed?: boolean;
  51690. updatable?: boolean;
  51691. sideOrientation?: number;
  51692. frontUVs?: Vector4;
  51693. backUVs?: Vector4;
  51694. cap?: number;
  51695. invertUV?: boolean;
  51696. }, scene?: Nullable<Scene>): Mesh;
  51697. /**
  51698. * Creates a tiled plane mesh
  51699. * * You can set a limited pattern arrangement with the tiles
  51700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51701. * * 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
  51702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51703. * @param name defines the name of the mesh
  51704. * @param options defines the options used to create the mesh
  51705. * @param scene defines the hosting scene
  51706. * @returns the plane mesh
  51707. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51708. */
  51709. static CreateTiledPlane(name: string, options: {
  51710. pattern?: number;
  51711. tileSize?: number;
  51712. tileWidth?: number;
  51713. tileHeight?: number;
  51714. size?: number;
  51715. width?: number;
  51716. height?: number;
  51717. alignHorizontal?: number;
  51718. alignVertical?: number;
  51719. sideOrientation?: number;
  51720. frontUVs?: Vector4;
  51721. backUVs?: Vector4;
  51722. updatable?: boolean;
  51723. }, scene?: Nullable<Scene>): Mesh;
  51724. /**
  51725. * Creates a plane mesh
  51726. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51727. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51728. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51730. * * 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
  51731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51732. * @param name defines the name of the mesh
  51733. * @param options defines the options used to create the mesh
  51734. * @param scene defines the hosting scene
  51735. * @returns the plane mesh
  51736. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51737. */
  51738. static CreatePlane(name: string, options: {
  51739. size?: number;
  51740. width?: number;
  51741. height?: number;
  51742. sideOrientation?: number;
  51743. frontUVs?: Vector4;
  51744. backUVs?: Vector4;
  51745. updatable?: boolean;
  51746. sourcePlane?: Plane;
  51747. }, scene?: Nullable<Scene>): Mesh;
  51748. /**
  51749. * Creates a ground mesh
  51750. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51751. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51753. * @param name defines the name of the mesh
  51754. * @param options defines the options used to create the mesh
  51755. * @param scene defines the hosting scene
  51756. * @returns the ground mesh
  51757. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51758. */
  51759. static CreateGround(name: string, options: {
  51760. width?: number;
  51761. height?: number;
  51762. subdivisions?: number;
  51763. subdivisionsX?: number;
  51764. subdivisionsY?: number;
  51765. updatable?: boolean;
  51766. }, scene?: Nullable<Scene>): Mesh;
  51767. /**
  51768. * Creates a tiled ground mesh
  51769. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51770. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51771. * * 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
  51772. * * 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
  51773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51774. * @param name defines the name of the mesh
  51775. * @param options defines the options used to create the mesh
  51776. * @param scene defines the hosting scene
  51777. * @returns the tiled ground mesh
  51778. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51779. */
  51780. static CreateTiledGround(name: string, options: {
  51781. xmin: number;
  51782. zmin: number;
  51783. xmax: number;
  51784. zmax: number;
  51785. subdivisions?: {
  51786. w: number;
  51787. h: number;
  51788. };
  51789. precision?: {
  51790. w: number;
  51791. h: number;
  51792. };
  51793. updatable?: boolean;
  51794. }, scene?: Nullable<Scene>): Mesh;
  51795. /**
  51796. * Creates a ground mesh from a height map
  51797. * * The parameter `url` sets the URL of the height map image resource.
  51798. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51799. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51800. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51801. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51802. * * 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.
  51803. * * 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).
  51804. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51806. * @param name defines the name of the mesh
  51807. * @param url defines the url to the height map
  51808. * @param options defines the options used to create the mesh
  51809. * @param scene defines the hosting scene
  51810. * @returns the ground mesh
  51811. * @see https://doc.babylonjs.com/babylon101/height_map
  51812. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51813. */
  51814. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51815. width?: number;
  51816. height?: number;
  51817. subdivisions?: number;
  51818. minHeight?: number;
  51819. maxHeight?: number;
  51820. colorFilter?: Color3;
  51821. alphaFilter?: number;
  51822. updatable?: boolean;
  51823. onReady?: (mesh: GroundMesh) => void;
  51824. }, scene?: Nullable<Scene>): GroundMesh;
  51825. /**
  51826. * Creates a polygon mesh
  51827. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51828. * * 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
  51829. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51831. * * 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)
  51832. * * Remember you can only change the shape positions, not their number when updating a polygon
  51833. * @param name defines the name of the mesh
  51834. * @param options defines the options used to create the mesh
  51835. * @param scene defines the hosting scene
  51836. * @param earcutInjection can be used to inject your own earcut reference
  51837. * @returns the polygon mesh
  51838. */
  51839. static CreatePolygon(name: string, options: {
  51840. shape: Vector3[];
  51841. holes?: Vector3[][];
  51842. depth?: number;
  51843. faceUV?: Vector4[];
  51844. faceColors?: Color4[];
  51845. updatable?: boolean;
  51846. sideOrientation?: number;
  51847. frontUVs?: Vector4;
  51848. backUVs?: Vector4;
  51849. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51850. /**
  51851. * Creates an extruded polygon mesh, with depth in the Y direction.
  51852. * * 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)
  51853. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51854. * @param name defines the name of the mesh
  51855. * @param options defines the options used to create the mesh
  51856. * @param scene defines the hosting scene
  51857. * @param earcutInjection can be used to inject your own earcut reference
  51858. * @returns the polygon mesh
  51859. */
  51860. static ExtrudePolygon(name: string, options: {
  51861. shape: Vector3[];
  51862. holes?: Vector3[][];
  51863. depth?: number;
  51864. faceUV?: Vector4[];
  51865. faceColors?: Color4[];
  51866. updatable?: boolean;
  51867. sideOrientation?: number;
  51868. frontUVs?: Vector4;
  51869. backUVs?: Vector4;
  51870. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51871. /**
  51872. * Creates a tube mesh.
  51873. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51874. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51875. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51876. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51877. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51878. * * 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)
  51879. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51880. * * 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
  51881. * * 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
  51882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51883. * * 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
  51884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51886. * @param name defines the name of the mesh
  51887. * @param options defines the options used to create the mesh
  51888. * @param scene defines the hosting scene
  51889. * @returns the tube mesh
  51890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51891. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51892. */
  51893. static CreateTube(name: string, options: {
  51894. path: Vector3[];
  51895. radius?: number;
  51896. tessellation?: number;
  51897. radiusFunction?: {
  51898. (i: number, distance: number): number;
  51899. };
  51900. cap?: number;
  51901. arc?: number;
  51902. updatable?: boolean;
  51903. sideOrientation?: number;
  51904. frontUVs?: Vector4;
  51905. backUVs?: Vector4;
  51906. instance?: Mesh;
  51907. invertUV?: boolean;
  51908. }, scene?: Nullable<Scene>): Mesh;
  51909. /**
  51910. * Creates a polyhedron mesh
  51911. * * 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
  51912. * * The parameter `size` (positive float, default 1) sets the polygon size
  51913. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51914. * * 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`
  51915. * * 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
  51916. * * 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)`)
  51917. * * 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
  51918. * * 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
  51919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51920. * * 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
  51921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51922. * @param name defines the name of the mesh
  51923. * @param options defines the options used to create the mesh
  51924. * @param scene defines the hosting scene
  51925. * @returns the polyhedron mesh
  51926. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51927. */
  51928. static CreatePolyhedron(name: string, options: {
  51929. type?: number;
  51930. size?: number;
  51931. sizeX?: number;
  51932. sizeY?: number;
  51933. sizeZ?: number;
  51934. custom?: any;
  51935. faceUV?: Vector4[];
  51936. faceColors?: Color4[];
  51937. flat?: boolean;
  51938. updatable?: boolean;
  51939. sideOrientation?: number;
  51940. frontUVs?: Vector4;
  51941. backUVs?: Vector4;
  51942. }, scene?: Nullable<Scene>): Mesh;
  51943. /**
  51944. * Creates a decal mesh.
  51945. * 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
  51946. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51947. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51948. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51949. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51950. * @param name defines the name of the mesh
  51951. * @param sourceMesh defines the mesh where the decal must be applied
  51952. * @param options defines the options used to create the mesh
  51953. * @param scene defines the hosting scene
  51954. * @returns the decal mesh
  51955. * @see https://doc.babylonjs.com/how_to/decals
  51956. */
  51957. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51958. position?: Vector3;
  51959. normal?: Vector3;
  51960. size?: Vector3;
  51961. angle?: number;
  51962. }): Mesh;
  51963. }
  51964. }
  51965. declare module BABYLON {
  51966. /**
  51967. * A simplifier interface for future simplification implementations
  51968. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51969. */
  51970. export interface ISimplifier {
  51971. /**
  51972. * Simplification of a given mesh according to the given settings.
  51973. * Since this requires computation, it is assumed that the function runs async.
  51974. * @param settings The settings of the simplification, including quality and distance
  51975. * @param successCallback A callback that will be called after the mesh was simplified.
  51976. * @param errorCallback in case of an error, this callback will be called. optional.
  51977. */
  51978. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51979. }
  51980. /**
  51981. * Expected simplification settings.
  51982. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51983. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51984. */
  51985. export interface ISimplificationSettings {
  51986. /**
  51987. * Gets or sets the expected quality
  51988. */
  51989. quality: number;
  51990. /**
  51991. * Gets or sets the distance when this optimized version should be used
  51992. */
  51993. distance: number;
  51994. /**
  51995. * Gets an already optimized mesh
  51996. */
  51997. optimizeMesh?: boolean;
  51998. }
  51999. /**
  52000. * Class used to specify simplification options
  52001. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52002. */
  52003. export class SimplificationSettings implements ISimplificationSettings {
  52004. /** expected quality */
  52005. quality: number;
  52006. /** distance when this optimized version should be used */
  52007. distance: number;
  52008. /** already optimized mesh */
  52009. optimizeMesh?: boolean | undefined;
  52010. /**
  52011. * Creates a SimplificationSettings
  52012. * @param quality expected quality
  52013. * @param distance distance when this optimized version should be used
  52014. * @param optimizeMesh already optimized mesh
  52015. */
  52016. constructor(
  52017. /** expected quality */
  52018. quality: number,
  52019. /** distance when this optimized version should be used */
  52020. distance: number,
  52021. /** already optimized mesh */
  52022. optimizeMesh?: boolean | undefined);
  52023. }
  52024. /**
  52025. * Interface used to define a simplification task
  52026. */
  52027. export interface ISimplificationTask {
  52028. /**
  52029. * Array of settings
  52030. */
  52031. settings: Array<ISimplificationSettings>;
  52032. /**
  52033. * Simplification type
  52034. */
  52035. simplificationType: SimplificationType;
  52036. /**
  52037. * Mesh to simplify
  52038. */
  52039. mesh: Mesh;
  52040. /**
  52041. * Callback called on success
  52042. */
  52043. successCallback?: () => void;
  52044. /**
  52045. * Defines if parallel processing can be used
  52046. */
  52047. parallelProcessing: boolean;
  52048. }
  52049. /**
  52050. * Queue used to order the simplification tasks
  52051. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52052. */
  52053. export class SimplificationQueue {
  52054. private _simplificationArray;
  52055. /**
  52056. * Gets a boolean indicating that the process is still running
  52057. */
  52058. running: boolean;
  52059. /**
  52060. * Creates a new queue
  52061. */
  52062. constructor();
  52063. /**
  52064. * Adds a new simplification task
  52065. * @param task defines a task to add
  52066. */
  52067. addTask(task: ISimplificationTask): void;
  52068. /**
  52069. * Execute next task
  52070. */
  52071. executeNext(): void;
  52072. /**
  52073. * Execute a simplification task
  52074. * @param task defines the task to run
  52075. */
  52076. runSimplification(task: ISimplificationTask): void;
  52077. private getSimplifier;
  52078. }
  52079. /**
  52080. * The implemented types of simplification
  52081. * At the moment only Quadratic Error Decimation is implemented
  52082. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52083. */
  52084. export enum SimplificationType {
  52085. /** Quadratic error decimation */
  52086. QUADRATIC = 0
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. interface Scene {
  52091. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  52092. /**
  52093. * Gets or sets the simplification queue attached to the scene
  52094. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52095. */
  52096. simplificationQueue: SimplificationQueue;
  52097. }
  52098. interface Mesh {
  52099. /**
  52100. * Simplify the mesh according to the given array of settings.
  52101. * Function will return immediately and will simplify async
  52102. * @param settings a collection of simplification settings
  52103. * @param parallelProcessing should all levels calculate parallel or one after the other
  52104. * @param simplificationType the type of simplification to run
  52105. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52106. * @returns the current mesh
  52107. */
  52108. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52109. }
  52110. /**
  52111. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52112. * created in a scene
  52113. */
  52114. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52115. /**
  52116. * The component name helpfull to identify the component in the list of scene components.
  52117. */
  52118. readonly name: string;
  52119. /**
  52120. * The scene the component belongs to.
  52121. */
  52122. scene: Scene;
  52123. /**
  52124. * Creates a new instance of the component for the given scene
  52125. * @param scene Defines the scene to register the component in
  52126. */
  52127. constructor(scene: Scene);
  52128. /**
  52129. * Registers the component in a given scene
  52130. */
  52131. register(): void;
  52132. /**
  52133. * Rebuilds the elements related to this component in case of
  52134. * context lost for instance.
  52135. */
  52136. rebuild(): void;
  52137. /**
  52138. * Disposes the component and the associated ressources
  52139. */
  52140. dispose(): void;
  52141. private _beforeCameraUpdate;
  52142. }
  52143. }
  52144. declare module BABYLON {
  52145. /**
  52146. * Class used to enable access to IndexedDB
  52147. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52148. */
  52149. export class Database implements IOfflineProvider {
  52150. private _callbackManifestChecked;
  52151. private _currentSceneUrl;
  52152. private _db;
  52153. private _enableSceneOffline;
  52154. private _enableTexturesOffline;
  52155. private _manifestVersionFound;
  52156. private _mustUpdateRessources;
  52157. private _hasReachedQuota;
  52158. private _isSupported;
  52159. private _idbFactory;
  52160. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52161. private static IsUASupportingBlobStorage;
  52162. /**
  52163. * Gets a boolean indicating if Database storate is enabled (off by default)
  52164. */
  52165. static IDBStorageEnabled: boolean;
  52166. /**
  52167. * Gets a boolean indicating if scene must be saved in the database
  52168. */
  52169. readonly enableSceneOffline: boolean;
  52170. /**
  52171. * Gets a boolean indicating if textures must be saved in the database
  52172. */
  52173. readonly enableTexturesOffline: boolean;
  52174. /**
  52175. * Creates a new Database
  52176. * @param urlToScene defines the url to load the scene
  52177. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52178. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52179. */
  52180. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52181. private static _ParseURL;
  52182. private static _ReturnFullUrlLocation;
  52183. private _checkManifestFile;
  52184. /**
  52185. * Open the database and make it available
  52186. * @param successCallback defines the callback to call on success
  52187. * @param errorCallback defines the callback to call on error
  52188. */
  52189. open(successCallback: () => void, errorCallback: () => void): void;
  52190. /**
  52191. * Loads an image from the database
  52192. * @param url defines the url to load from
  52193. * @param image defines the target DOM image
  52194. */
  52195. loadImage(url: string, image: HTMLImageElement): void;
  52196. private _loadImageFromDBAsync;
  52197. private _saveImageIntoDBAsync;
  52198. private _checkVersionFromDB;
  52199. private _loadVersionFromDBAsync;
  52200. private _saveVersionIntoDBAsync;
  52201. /**
  52202. * Loads a file from database
  52203. * @param url defines the URL to load from
  52204. * @param sceneLoaded defines a callback to call on success
  52205. * @param progressCallBack defines a callback to call when progress changed
  52206. * @param errorCallback defines a callback to call on error
  52207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52208. */
  52209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52210. private _loadFileAsync;
  52211. private _saveFileAsync;
  52212. /**
  52213. * Validates if xhr data is correct
  52214. * @param xhr defines the request to validate
  52215. * @param dataType defines the expected data type
  52216. * @returns true if data is correct
  52217. */
  52218. private static _ValidateXHRData;
  52219. }
  52220. }
  52221. declare module BABYLON {
  52222. /** @hidden */
  52223. export var gpuUpdateParticlesPixelShader: {
  52224. name: string;
  52225. shader: string;
  52226. };
  52227. }
  52228. declare module BABYLON {
  52229. /** @hidden */
  52230. export var gpuUpdateParticlesVertexShader: {
  52231. name: string;
  52232. shader: string;
  52233. };
  52234. }
  52235. declare module BABYLON {
  52236. /** @hidden */
  52237. export var clipPlaneFragmentDeclaration2: {
  52238. name: string;
  52239. shader: string;
  52240. };
  52241. }
  52242. declare module BABYLON {
  52243. /** @hidden */
  52244. export var gpuRenderParticlesPixelShader: {
  52245. name: string;
  52246. shader: string;
  52247. };
  52248. }
  52249. declare module BABYLON {
  52250. /** @hidden */
  52251. export var clipPlaneVertexDeclaration2: {
  52252. name: string;
  52253. shader: string;
  52254. };
  52255. }
  52256. declare module BABYLON {
  52257. /** @hidden */
  52258. export var gpuRenderParticlesVertexShader: {
  52259. name: string;
  52260. shader: string;
  52261. };
  52262. }
  52263. declare module BABYLON {
  52264. /**
  52265. * This represents a GPU particle system in Babylon
  52266. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52267. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52268. */
  52269. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52270. /**
  52271. * The layer mask we are rendering the particles through.
  52272. */
  52273. layerMask: number;
  52274. private _capacity;
  52275. private _activeCount;
  52276. private _currentActiveCount;
  52277. private _accumulatedCount;
  52278. private _renderEffect;
  52279. private _updateEffect;
  52280. private _buffer0;
  52281. private _buffer1;
  52282. private _spriteBuffer;
  52283. private _updateVAO;
  52284. private _renderVAO;
  52285. private _targetIndex;
  52286. private _sourceBuffer;
  52287. private _targetBuffer;
  52288. private _engine;
  52289. private _currentRenderId;
  52290. private _started;
  52291. private _stopped;
  52292. private _timeDelta;
  52293. private _randomTexture;
  52294. private _randomTexture2;
  52295. private _attributesStrideSize;
  52296. private _updateEffectOptions;
  52297. private _randomTextureSize;
  52298. private _actualFrame;
  52299. private readonly _rawTextureWidth;
  52300. /**
  52301. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52302. */
  52303. static readonly IsSupported: boolean;
  52304. /**
  52305. * An event triggered when the system is disposed.
  52306. */
  52307. onDisposeObservable: Observable<GPUParticleSystem>;
  52308. /**
  52309. * Gets the maximum number of particles active at the same time.
  52310. * @returns The max number of active particles.
  52311. */
  52312. getCapacity(): number;
  52313. /**
  52314. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52315. * to override the particles.
  52316. */
  52317. forceDepthWrite: boolean;
  52318. /**
  52319. * Gets or set the number of active particles
  52320. */
  52321. activeParticleCount: number;
  52322. private _preWarmDone;
  52323. /**
  52324. * Is this system ready to be used/rendered
  52325. * @return true if the system is ready
  52326. */
  52327. isReady(): boolean;
  52328. /**
  52329. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52330. * @returns True if it has been started, otherwise false.
  52331. */
  52332. isStarted(): boolean;
  52333. /**
  52334. * Starts the particle system and begins to emit
  52335. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52336. */
  52337. start(delay?: number): void;
  52338. /**
  52339. * Stops the particle system.
  52340. */
  52341. stop(): void;
  52342. /**
  52343. * Remove all active particles
  52344. */
  52345. reset(): void;
  52346. /**
  52347. * Returns the string "GPUParticleSystem"
  52348. * @returns a string containing the class name
  52349. */
  52350. getClassName(): string;
  52351. private _colorGradientsTexture;
  52352. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52353. /**
  52354. * Adds a new color gradient
  52355. * @param gradient defines the gradient to use (between 0 and 1)
  52356. * @param color1 defines the color to affect to the specified gradient
  52357. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52358. * @returns the current particle system
  52359. */
  52360. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52361. /**
  52362. * Remove a specific color gradient
  52363. * @param gradient defines the gradient to remove
  52364. * @returns the current particle system
  52365. */
  52366. removeColorGradient(gradient: number): GPUParticleSystem;
  52367. private _angularSpeedGradientsTexture;
  52368. private _sizeGradientsTexture;
  52369. private _velocityGradientsTexture;
  52370. private _limitVelocityGradientsTexture;
  52371. private _dragGradientsTexture;
  52372. private _addFactorGradient;
  52373. /**
  52374. * Adds a new size gradient
  52375. * @param gradient defines the gradient to use (between 0 and 1)
  52376. * @param factor defines the size factor to affect to the specified gradient
  52377. * @returns the current particle system
  52378. */
  52379. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52380. /**
  52381. * Remove a specific size gradient
  52382. * @param gradient defines the gradient to remove
  52383. * @returns the current particle system
  52384. */
  52385. removeSizeGradient(gradient: number): GPUParticleSystem;
  52386. /**
  52387. * Adds a new angular speed gradient
  52388. * @param gradient defines the gradient to use (between 0 and 1)
  52389. * @param factor defines the angular speed to affect to the specified gradient
  52390. * @returns the current particle system
  52391. */
  52392. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52393. /**
  52394. * Remove a specific angular speed gradient
  52395. * @param gradient defines the gradient to remove
  52396. * @returns the current particle system
  52397. */
  52398. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52399. /**
  52400. * Adds a new velocity gradient
  52401. * @param gradient defines the gradient to use (between 0 and 1)
  52402. * @param factor defines the velocity to affect to the specified gradient
  52403. * @returns the current particle system
  52404. */
  52405. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52406. /**
  52407. * Remove a specific velocity gradient
  52408. * @param gradient defines the gradient to remove
  52409. * @returns the current particle system
  52410. */
  52411. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52412. /**
  52413. * Adds a new limit velocity gradient
  52414. * @param gradient defines the gradient to use (between 0 and 1)
  52415. * @param factor defines the limit velocity value to affect to the specified gradient
  52416. * @returns the current particle system
  52417. */
  52418. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52419. /**
  52420. * Remove a specific limit velocity gradient
  52421. * @param gradient defines the gradient to remove
  52422. * @returns the current particle system
  52423. */
  52424. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52425. /**
  52426. * Adds a new drag gradient
  52427. * @param gradient defines the gradient to use (between 0 and 1)
  52428. * @param factor defines the drag value to affect to the specified gradient
  52429. * @returns the current particle system
  52430. */
  52431. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52432. /**
  52433. * Remove a specific drag gradient
  52434. * @param gradient defines the gradient to remove
  52435. * @returns the current particle system
  52436. */
  52437. removeDragGradient(gradient: number): GPUParticleSystem;
  52438. /**
  52439. * Not supported by GPUParticleSystem
  52440. * @param gradient defines the gradient to use (between 0 and 1)
  52441. * @param factor defines the emit rate value to affect to the specified gradient
  52442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52443. * @returns the current particle system
  52444. */
  52445. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52446. /**
  52447. * Not supported by GPUParticleSystem
  52448. * @param gradient defines the gradient to remove
  52449. * @returns the current particle system
  52450. */
  52451. removeEmitRateGradient(gradient: number): IParticleSystem;
  52452. /**
  52453. * Not supported by GPUParticleSystem
  52454. * @param gradient defines the gradient to use (between 0 and 1)
  52455. * @param factor defines the start size value to affect to the specified gradient
  52456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52457. * @returns the current particle system
  52458. */
  52459. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52460. /**
  52461. * Not supported by GPUParticleSystem
  52462. * @param gradient defines the gradient to remove
  52463. * @returns the current particle system
  52464. */
  52465. removeStartSizeGradient(gradient: number): IParticleSystem;
  52466. /**
  52467. * Not supported by GPUParticleSystem
  52468. * @param gradient defines the gradient to use (between 0 and 1)
  52469. * @param min defines the color remap minimal range
  52470. * @param max defines the color remap maximal range
  52471. * @returns the current particle system
  52472. */
  52473. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52474. /**
  52475. * Not supported by GPUParticleSystem
  52476. * @param gradient defines the gradient to remove
  52477. * @returns the current particle system
  52478. */
  52479. removeColorRemapGradient(): IParticleSystem;
  52480. /**
  52481. * Not supported by GPUParticleSystem
  52482. * @param gradient defines the gradient to use (between 0 and 1)
  52483. * @param min defines the alpha remap minimal range
  52484. * @param max defines the alpha remap maximal range
  52485. * @returns the current particle system
  52486. */
  52487. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52488. /**
  52489. * Not supported by GPUParticleSystem
  52490. * @param gradient defines the gradient to remove
  52491. * @returns the current particle system
  52492. */
  52493. removeAlphaRemapGradient(): IParticleSystem;
  52494. /**
  52495. * Not supported by GPUParticleSystem
  52496. * @param gradient defines the gradient to use (between 0 and 1)
  52497. * @param color defines the color to affect to the specified gradient
  52498. * @returns the current particle system
  52499. */
  52500. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52501. /**
  52502. * Not supported by GPUParticleSystem
  52503. * @param gradient defines the gradient to remove
  52504. * @returns the current particle system
  52505. */
  52506. removeRampGradient(): IParticleSystem;
  52507. /**
  52508. * Not supported by GPUParticleSystem
  52509. * @returns the list of ramp gradients
  52510. */
  52511. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52512. /**
  52513. * Not supported by GPUParticleSystem
  52514. * Gets or sets a boolean indicating that ramp gradients must be used
  52515. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52516. */
  52517. useRampGradients: boolean;
  52518. /**
  52519. * Not supported by GPUParticleSystem
  52520. * @param gradient defines the gradient to use (between 0 and 1)
  52521. * @param factor defines the life time factor to affect to the specified gradient
  52522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52523. * @returns the current particle system
  52524. */
  52525. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52526. /**
  52527. * Not supported by GPUParticleSystem
  52528. * @param gradient defines the gradient to remove
  52529. * @returns the current particle system
  52530. */
  52531. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52532. /**
  52533. * Instantiates a GPU particle system.
  52534. * 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.
  52535. * @param name The name of the particle system
  52536. * @param options The options used to create the system
  52537. * @param scene The scene the particle system belongs to
  52538. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52539. */
  52540. constructor(name: string, options: Partial<{
  52541. capacity: number;
  52542. randomTextureSize: number;
  52543. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52544. protected _reset(): void;
  52545. private _createUpdateVAO;
  52546. private _createRenderVAO;
  52547. private _initialize;
  52548. /** @hidden */ private _recreateUpdateEffect(): void;
  52549. /** @hidden */ private _recreateRenderEffect(): void;
  52550. /**
  52551. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52552. * @param preWarm defines if we are in the pre-warmimg phase
  52553. */
  52554. animate(preWarm?: boolean): void;
  52555. private _createFactorGradientTexture;
  52556. private _createSizeGradientTexture;
  52557. private _createAngularSpeedGradientTexture;
  52558. private _createVelocityGradientTexture;
  52559. private _createLimitVelocityGradientTexture;
  52560. private _createDragGradientTexture;
  52561. private _createColorGradientTexture;
  52562. /**
  52563. * Renders the particle system in its current state
  52564. * @param preWarm defines if the system should only update the particles but not render them
  52565. * @returns the current number of particles
  52566. */
  52567. render(preWarm?: boolean): number;
  52568. /**
  52569. * Rebuilds the particle system
  52570. */
  52571. rebuild(): void;
  52572. private _releaseBuffers;
  52573. private _releaseVAOs;
  52574. /**
  52575. * Disposes the particle system and free the associated resources
  52576. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52577. */
  52578. dispose(disposeTexture?: boolean): void;
  52579. /**
  52580. * Clones the particle system.
  52581. * @param name The name of the cloned object
  52582. * @param newEmitter The new emitter to use
  52583. * @returns the cloned particle system
  52584. */
  52585. clone(name: string, newEmitter: any): GPUParticleSystem;
  52586. /**
  52587. * Serializes the particle system to a JSON object.
  52588. * @returns the JSON object
  52589. */
  52590. serialize(): any;
  52591. /**
  52592. * Parses a JSON object to create a GPU particle system.
  52593. * @param parsedParticleSystem The JSON object to parse
  52594. * @param scene The scene to create the particle system in
  52595. * @param rootUrl The root url to use to load external dependencies like texture
  52596. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52597. * @returns the parsed GPU particle system
  52598. */
  52599. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52600. }
  52601. }
  52602. declare module BABYLON {
  52603. /**
  52604. * Represents a set of particle systems working together to create a specific effect
  52605. */
  52606. export class ParticleSystemSet implements IDisposable {
  52607. private _emitterCreationOptions;
  52608. private _emitterNode;
  52609. /**
  52610. * Gets the particle system list
  52611. */
  52612. systems: IParticleSystem[];
  52613. /**
  52614. * Gets the emitter node used with this set
  52615. */
  52616. readonly emitterNode: Nullable<TransformNode>;
  52617. /**
  52618. * Creates a new emitter mesh as a sphere
  52619. * @param options defines the options used to create the sphere
  52620. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52621. * @param scene defines the hosting scene
  52622. */
  52623. setEmitterAsSphere(options: {
  52624. diameter: number;
  52625. segments: number;
  52626. color: Color3;
  52627. }, renderingGroupId: number, scene: Scene): void;
  52628. /**
  52629. * Starts all particle systems of the set
  52630. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52631. */
  52632. start(emitter?: AbstractMesh): void;
  52633. /**
  52634. * Release all associated resources
  52635. */
  52636. dispose(): void;
  52637. /**
  52638. * Serialize the set into a JSON compatible object
  52639. * @returns a JSON compatible representation of the set
  52640. */
  52641. serialize(): any;
  52642. /**
  52643. * Parse a new ParticleSystemSet from a serialized source
  52644. * @param data defines a JSON compatible representation of the set
  52645. * @param scene defines the hosting scene
  52646. * @param gpu defines if we want GPU particles or CPU particles
  52647. * @returns a new ParticleSystemSet
  52648. */
  52649. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52650. }
  52651. }
  52652. declare module BABYLON {
  52653. /**
  52654. * This class is made for on one-liner static method to help creating particle system set.
  52655. */
  52656. export class ParticleHelper {
  52657. /**
  52658. * Gets or sets base Assets URL
  52659. */
  52660. static BaseAssetsUrl: string;
  52661. /**
  52662. * Create a default particle system that you can tweak
  52663. * @param emitter defines the emitter to use
  52664. * @param capacity defines the system capacity (default is 500 particles)
  52665. * @param scene defines the hosting scene
  52666. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52667. * @returns the new Particle system
  52668. */
  52669. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52670. /**
  52671. * This is the main static method (one-liner) of this helper to create different particle systems
  52672. * @param type This string represents the type to the particle system to create
  52673. * @param scene The scene where the particle system should live
  52674. * @param gpu If the system will use gpu
  52675. * @returns the ParticleSystemSet created
  52676. */
  52677. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52678. /**
  52679. * Static function used to export a particle system to a ParticleSystemSet variable.
  52680. * Please note that the emitter shape is not exported
  52681. * @param systems defines the particle systems to export
  52682. * @returns the created particle system set
  52683. */
  52684. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52685. }
  52686. }
  52687. declare module BABYLON {
  52688. interface Engine {
  52689. /**
  52690. * Create an effect to use with particle systems.
  52691. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52692. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52693. * @param uniformsNames defines a list of attribute names
  52694. * @param samplers defines an array of string used to represent textures
  52695. * @param defines defines the string containing the defines to use to compile the shaders
  52696. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52697. * @param onCompiled defines a function to call when the effect creation is successful
  52698. * @param onError defines a function to call when the effect creation has failed
  52699. * @returns the new Effect
  52700. */
  52701. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52702. }
  52703. interface Mesh {
  52704. /**
  52705. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52706. * @returns an array of IParticleSystem
  52707. */
  52708. getEmittedParticleSystems(): IParticleSystem[];
  52709. /**
  52710. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52711. * @returns an array of IParticleSystem
  52712. */
  52713. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52714. }
  52715. /**
  52716. * @hidden
  52717. */
  52718. export var _IDoNeedToBeInTheBuild: number;
  52719. }
  52720. declare module BABYLON {
  52721. interface Scene {
  52722. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  52723. /**
  52724. * Gets the current physics engine
  52725. * @returns a IPhysicsEngine or null if none attached
  52726. */
  52727. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52728. /**
  52729. * Enables physics to the current scene
  52730. * @param gravity defines the scene's gravity for the physics engine
  52731. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52732. * @return a boolean indicating if the physics engine was initialized
  52733. */
  52734. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52735. /**
  52736. * Disables and disposes the physics engine associated with the scene
  52737. */
  52738. disablePhysicsEngine(): void;
  52739. /**
  52740. * Gets a boolean indicating if there is an active physics engine
  52741. * @returns a boolean indicating if there is an active physics engine
  52742. */
  52743. isPhysicsEnabled(): boolean;
  52744. /**
  52745. * Deletes a physics compound impostor
  52746. * @param compound defines the compound to delete
  52747. */
  52748. deleteCompoundImpostor(compound: any): void;
  52749. /**
  52750. * An event triggered when physic simulation is about to be run
  52751. */
  52752. onBeforePhysicsObservable: Observable<Scene>;
  52753. /**
  52754. * An event triggered when physic simulation has been done
  52755. */
  52756. onAfterPhysicsObservable: Observable<Scene>;
  52757. }
  52758. interface AbstractMesh {
  52759. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  52760. /**
  52761. * Gets or sets impostor used for physic simulation
  52762. * @see http://doc.babylonjs.com/features/physics_engine
  52763. */
  52764. physicsImpostor: Nullable<PhysicsImpostor>;
  52765. /**
  52766. * Gets the current physics impostor
  52767. * @see http://doc.babylonjs.com/features/physics_engine
  52768. * @returns a physics impostor or null
  52769. */
  52770. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52771. /** Apply a physic impulse to the mesh
  52772. * @param force defines the force to apply
  52773. * @param contactPoint defines where to apply the force
  52774. * @returns the current mesh
  52775. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52776. */
  52777. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52778. /**
  52779. * Creates a physic joint between two meshes
  52780. * @param otherMesh defines the other mesh to use
  52781. * @param pivot1 defines the pivot to use on this mesh
  52782. * @param pivot2 defines the pivot to use on the other mesh
  52783. * @param options defines additional options (can be plugin dependent)
  52784. * @returns the current mesh
  52785. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52786. */
  52787. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52788. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  52789. }
  52790. /**
  52791. * Defines the physics engine scene component responsible to manage a physics engine
  52792. */
  52793. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52794. /**
  52795. * The component name helpful to identify the component in the list of scene components.
  52796. */
  52797. readonly name: string;
  52798. /**
  52799. * The scene the component belongs to.
  52800. */
  52801. scene: Scene;
  52802. /**
  52803. * Creates a new instance of the component for the given scene
  52804. * @param scene Defines the scene to register the component in
  52805. */
  52806. constructor(scene: Scene);
  52807. /**
  52808. * Registers the component in a given scene
  52809. */
  52810. register(): void;
  52811. /**
  52812. * Rebuilds the elements related to this component in case of
  52813. * context lost for instance.
  52814. */
  52815. rebuild(): void;
  52816. /**
  52817. * Disposes the component and the associated ressources
  52818. */
  52819. dispose(): void;
  52820. }
  52821. }
  52822. declare module BABYLON {
  52823. /**
  52824. * A helper for physics simulations
  52825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52826. */
  52827. export class PhysicsHelper {
  52828. private _scene;
  52829. private _physicsEngine;
  52830. /**
  52831. * Initializes the Physics helper
  52832. * @param scene Babylon.js scene
  52833. */
  52834. constructor(scene: Scene);
  52835. /**
  52836. * Applies a radial explosion impulse
  52837. * @param origin the origin of the explosion
  52838. * @param radiusOrEventOptions the radius or the options of radial explosion
  52839. * @param strength the explosion strength
  52840. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52841. * @returns A physics radial explosion event, or null
  52842. */
  52843. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52844. /**
  52845. * Applies a radial explosion force
  52846. * @param origin the origin of the explosion
  52847. * @param radiusOrEventOptions the radius or the options of radial explosion
  52848. * @param strength the explosion strength
  52849. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52850. * @returns A physics radial explosion event, or null
  52851. */
  52852. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52853. /**
  52854. * Creates a gravitational field
  52855. * @param origin the origin of the explosion
  52856. * @param radiusOrEventOptions the radius or the options of radial explosion
  52857. * @param strength the explosion strength
  52858. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52859. * @returns A physics gravitational field event, or null
  52860. */
  52861. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52862. /**
  52863. * Creates a physics updraft event
  52864. * @param origin the origin of the updraft
  52865. * @param radiusOrEventOptions the radius or the options of the updraft
  52866. * @param strength the strength of the updraft
  52867. * @param height the height of the updraft
  52868. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52869. * @returns A physics updraft event, or null
  52870. */
  52871. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52872. /**
  52873. * Creates a physics vortex event
  52874. * @param origin the of the vortex
  52875. * @param radiusOrEventOptions the radius or the options of the vortex
  52876. * @param strength the strength of the vortex
  52877. * @param height the height of the vortex
  52878. * @returns a Physics vortex event, or null
  52879. * A physics vortex event or null
  52880. */
  52881. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52882. }
  52883. /**
  52884. * Represents a physics radial explosion event
  52885. */
  52886. class PhysicsRadialExplosionEvent {
  52887. private _scene;
  52888. private _options;
  52889. private _sphere;
  52890. private _dataFetched;
  52891. /**
  52892. * Initializes a radial explosioin event
  52893. * @param _scene BabylonJS scene
  52894. * @param _options The options for the vortex event
  52895. */
  52896. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52897. /**
  52898. * Returns the data related to the radial explosion event (sphere).
  52899. * @returns The radial explosion event data
  52900. */
  52901. getData(): PhysicsRadialExplosionEventData;
  52902. /**
  52903. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52904. * @param impostor A physics imposter
  52905. * @param origin the origin of the explosion
  52906. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  52907. */
  52908. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  52909. /**
  52910. * Triggers affecterd impostors callbacks
  52911. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  52912. */
  52913. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  52914. /**
  52915. * Disposes the sphere.
  52916. * @param force Specifies if the sphere should be disposed by force
  52917. */
  52918. dispose(force?: boolean): void;
  52919. /*** Helpers ***/
  52920. private _prepareSphere;
  52921. private _intersectsWithSphere;
  52922. }
  52923. /**
  52924. * Represents a gravitational field event
  52925. */
  52926. class PhysicsGravitationalFieldEvent {
  52927. private _physicsHelper;
  52928. private _scene;
  52929. private _origin;
  52930. private _options;
  52931. private _tickCallback;
  52932. private _sphere;
  52933. private _dataFetched;
  52934. /**
  52935. * Initializes the physics gravitational field event
  52936. * @param _physicsHelper A physics helper
  52937. * @param _scene BabylonJS scene
  52938. * @param _origin The origin position of the gravitational field event
  52939. * @param _options The options for the vortex event
  52940. */
  52941. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52942. /**
  52943. * Returns the data related to the gravitational field event (sphere).
  52944. * @returns A gravitational field event
  52945. */
  52946. getData(): PhysicsGravitationalFieldEventData;
  52947. /**
  52948. * Enables the gravitational field.
  52949. */
  52950. enable(): void;
  52951. /**
  52952. * Disables the gravitational field.
  52953. */
  52954. disable(): void;
  52955. /**
  52956. * Disposes the sphere.
  52957. * @param force The force to dispose from the gravitational field event
  52958. */
  52959. dispose(force?: boolean): void;
  52960. private _tick;
  52961. }
  52962. /**
  52963. * Represents a physics updraft event
  52964. */
  52965. class PhysicsUpdraftEvent {
  52966. private _scene;
  52967. private _origin;
  52968. private _options;
  52969. private _physicsEngine;
  52970. private _originTop;
  52971. private _originDirection;
  52972. private _tickCallback;
  52973. private _cylinder;
  52974. private _cylinderPosition;
  52975. private _dataFetched;
  52976. /**
  52977. * Initializes the physics updraft event
  52978. * @param _scene BabylonJS scene
  52979. * @param _origin The origin position of the updraft
  52980. * @param _options The options for the updraft event
  52981. */
  52982. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52983. /**
  52984. * Returns the data related to the updraft event (cylinder).
  52985. * @returns A physics updraft event
  52986. */
  52987. getData(): PhysicsUpdraftEventData;
  52988. /**
  52989. * Enables the updraft.
  52990. */
  52991. enable(): void;
  52992. /**
  52993. * Disables the updraft.
  52994. */
  52995. disable(): void;
  52996. /**
  52997. * Disposes the cylinder.
  52998. * @param force Specifies if the updraft should be disposed by force
  52999. */
  53000. dispose(force?: boolean): void;
  53001. private getImpostorHitData;
  53002. private _tick;
  53003. /*** Helpers ***/
  53004. private _prepareCylinder;
  53005. private _intersectsWithCylinder;
  53006. }
  53007. /**
  53008. * Represents a physics vortex event
  53009. */
  53010. class PhysicsVortexEvent {
  53011. private _scene;
  53012. private _origin;
  53013. private _options;
  53014. private _physicsEngine;
  53015. private _originTop;
  53016. private _tickCallback;
  53017. private _cylinder;
  53018. private _cylinderPosition;
  53019. private _dataFetched;
  53020. /**
  53021. * Initializes the physics vortex event
  53022. * @param _scene The BabylonJS scene
  53023. * @param _origin The origin position of the vortex
  53024. * @param _options The options for the vortex event
  53025. */
  53026. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53027. /**
  53028. * Returns the data related to the vortex event (cylinder).
  53029. * @returns The physics vortex event data
  53030. */
  53031. getData(): PhysicsVortexEventData;
  53032. /**
  53033. * Enables the vortex.
  53034. */
  53035. enable(): void;
  53036. /**
  53037. * Disables the cortex.
  53038. */
  53039. disable(): void;
  53040. /**
  53041. * Disposes the sphere.
  53042. * @param force
  53043. */
  53044. dispose(force?: boolean): void;
  53045. private getImpostorHitData;
  53046. private _tick;
  53047. /*** Helpers ***/
  53048. private _prepareCylinder;
  53049. private _intersectsWithCylinder;
  53050. }
  53051. /**
  53052. * Options fot the radial explosion event
  53053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53054. */
  53055. export class PhysicsRadialExplosionEventOptions {
  53056. /**
  53057. * The radius of the sphere for the radial explosion.
  53058. */
  53059. radius: number;
  53060. /**
  53061. * The strenth of the explosion.
  53062. */
  53063. strength: number;
  53064. /**
  53065. * The strenght of the force in correspondence to the distance of the affected object
  53066. */
  53067. falloff: PhysicsRadialImpulseFalloff;
  53068. /**
  53069. * Sphere options for the radial explosion.
  53070. */
  53071. sphere: {
  53072. segments: number;
  53073. diameter: number;
  53074. };
  53075. /**
  53076. * Sphere options for the radial explosion.
  53077. */
  53078. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53079. }
  53080. /**
  53081. * Options fot the updraft event
  53082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53083. */
  53084. export class PhysicsUpdraftEventOptions {
  53085. /**
  53086. * The radius of the cylinder for the vortex
  53087. */
  53088. radius: number;
  53089. /**
  53090. * The strenth of the updraft.
  53091. */
  53092. strength: number;
  53093. /**
  53094. * The height of the cylinder for the updraft.
  53095. */
  53096. height: number;
  53097. /**
  53098. * The mode for the the updraft.
  53099. */
  53100. updraftMode: PhysicsUpdraftMode;
  53101. }
  53102. /**
  53103. * Options fot the vortex event
  53104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53105. */
  53106. export class PhysicsVortexEventOptions {
  53107. /**
  53108. * The radius of the cylinder for the vortex
  53109. */
  53110. radius: number;
  53111. /**
  53112. * The strenth of the vortex.
  53113. */
  53114. strength: number;
  53115. /**
  53116. * The height of the cylinder for the vortex.
  53117. */
  53118. height: number;
  53119. /**
  53120. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53121. */
  53122. centripetalForceThreshold: number;
  53123. /**
  53124. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53125. */
  53126. centripetalForceMultiplier: number;
  53127. /**
  53128. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53129. */
  53130. centrifugalForceMultiplier: number;
  53131. /**
  53132. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53133. */
  53134. updraftForceMultiplier: number;
  53135. }
  53136. /**
  53137. * The strenght of the force in correspondence to the distance of the affected object
  53138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53139. */
  53140. export enum PhysicsRadialImpulseFalloff {
  53141. /** Defines that impulse is constant in strength across it's whole radius */
  53142. Constant = 0,
  53143. /** Defines that impulse gets weaker if it's further from the origin */
  53144. Linear = 1
  53145. }
  53146. /**
  53147. * The strength of the force in correspondence to the distance of the affected object
  53148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53149. */
  53150. export enum PhysicsUpdraftMode {
  53151. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53152. Center = 0,
  53153. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53154. Perpendicular = 1
  53155. }
  53156. /**
  53157. * Interface for a physics hit data
  53158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53159. */
  53160. export interface PhysicsHitData {
  53161. /**
  53162. * The force applied at the contact point
  53163. */
  53164. force: Vector3;
  53165. /**
  53166. * The contact point
  53167. */
  53168. contactPoint: Vector3;
  53169. /**
  53170. * The distance from the origin to the contact point
  53171. */
  53172. distanceFromOrigin: number;
  53173. }
  53174. /**
  53175. * Interface for radial explosion event data
  53176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53177. */
  53178. export interface PhysicsRadialExplosionEventData {
  53179. /**
  53180. * A sphere used for the radial explosion event
  53181. */
  53182. sphere: Mesh;
  53183. }
  53184. /**
  53185. * Interface for gravitational field event data
  53186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53187. */
  53188. export interface PhysicsGravitationalFieldEventData {
  53189. /**
  53190. * A sphere mesh used for the gravitational field event
  53191. */
  53192. sphere: Mesh;
  53193. }
  53194. /**
  53195. * Interface for updraft event data
  53196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53197. */
  53198. export interface PhysicsUpdraftEventData {
  53199. /**
  53200. * A cylinder used for the updraft event
  53201. */
  53202. cylinder: Mesh;
  53203. }
  53204. /**
  53205. * Interface for vortex event data
  53206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53207. */
  53208. export interface PhysicsVortexEventData {
  53209. /**
  53210. * A cylinder used for the vortex event
  53211. */
  53212. cylinder: Mesh;
  53213. }
  53214. /**
  53215. * Interface for an affected physics impostor
  53216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53217. */
  53218. export interface PhysicsAffectedImpostorWithData {
  53219. /**
  53220. * The impostor affected by the effect
  53221. */
  53222. impostor: PhysicsImpostor;
  53223. /**
  53224. * The data about the hit/horce from the explosion
  53225. */
  53226. hitData: PhysicsHitData;
  53227. }
  53228. }
  53229. declare module BABYLON {
  53230. /** @hidden */
  53231. export var blackAndWhitePixelShader: {
  53232. name: string;
  53233. shader: string;
  53234. };
  53235. }
  53236. declare module BABYLON {
  53237. /**
  53238. * Post process used to render in black and white
  53239. */
  53240. export class BlackAndWhitePostProcess extends PostProcess {
  53241. /**
  53242. * Linear about to convert he result to black and white (default: 1)
  53243. */
  53244. degree: number;
  53245. /**
  53246. * Creates a black and white post process
  53247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53248. * @param name The name of the effect.
  53249. * @param options The required width/height ratio to downsize to before computing the render pass.
  53250. * @param camera The camera to apply the render pass to.
  53251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53252. * @param engine The engine which the post process will be applied. (default: current engine)
  53253. * @param reusable If the post process can be reused on the same frame. (default: false)
  53254. */
  53255. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53256. }
  53257. }
  53258. declare module BABYLON {
  53259. /**
  53260. * This represents a set of one or more post processes in Babylon.
  53261. * A post process can be used to apply a shader to a texture after it is rendered.
  53262. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53263. */
  53264. export class PostProcessRenderEffect {
  53265. private _postProcesses;
  53266. private _getPostProcesses;
  53267. private _singleInstance;
  53268. private _cameras;
  53269. private _indicesForCamera;
  53270. /**
  53271. * Name of the effect
  53272. * @hidden
  53273. */ private _name: string;
  53274. /**
  53275. * Instantiates a post process render effect.
  53276. * A post process can be used to apply a shader to a texture after it is rendered.
  53277. * @param engine The engine the effect is tied to
  53278. * @param name The name of the effect
  53279. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53280. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53281. */
  53282. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53283. /**
  53284. * Checks if all the post processes in the effect are supported.
  53285. */
  53286. readonly isSupported: boolean;
  53287. /**
  53288. * Updates the current state of the effect
  53289. * @hidden
  53290. */ private _update(): void;
  53291. /**
  53292. * Attaches the effect on cameras
  53293. * @param cameras The camera to attach to.
  53294. * @hidden
  53295. */ private _attachCameras(cameras: Camera): void;
  53296. /**
  53297. * Attaches the effect on cameras
  53298. * @param cameras The camera to attach to.
  53299. * @hidden
  53300. */ private _attachCameras(cameras: Camera[]): void;
  53301. /**
  53302. * Detaches the effect on cameras
  53303. * @param cameras The camera to detatch from.
  53304. * @hidden
  53305. */ private _detachCameras(cameras: Camera): void;
  53306. /**
  53307. * Detatches the effect on cameras
  53308. * @param cameras The camera to detatch from.
  53309. * @hidden
  53310. */ private _detachCameras(cameras: Camera[]): void;
  53311. /**
  53312. * Enables the effect on given cameras
  53313. * @param cameras The camera to enable.
  53314. * @hidden
  53315. */ private _enable(cameras: Camera): void;
  53316. /**
  53317. * Enables the effect on given cameras
  53318. * @param cameras The camera to enable.
  53319. * @hidden
  53320. */ private _enable(cameras: Nullable<Camera[]>): void;
  53321. /**
  53322. * Disables the effect on the given cameras
  53323. * @param cameras The camera to disable.
  53324. * @hidden
  53325. */ private _disable(cameras: Camera): void;
  53326. /**
  53327. * Disables the effect on the given cameras
  53328. * @param cameras The camera to disable.
  53329. * @hidden
  53330. */ private _disable(cameras: Nullable<Camera[]>): void;
  53331. /**
  53332. * Gets a list of the post processes contained in the effect.
  53333. * @param camera The camera to get the post processes on.
  53334. * @returns The list of the post processes in the effect.
  53335. */
  53336. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53337. }
  53338. }
  53339. declare module BABYLON {
  53340. /** @hidden */
  53341. export var extractHighlightsPixelShader: {
  53342. name: string;
  53343. shader: string;
  53344. };
  53345. }
  53346. declare module BABYLON {
  53347. /**
  53348. * 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.
  53349. */
  53350. export class ExtractHighlightsPostProcess extends PostProcess {
  53351. /**
  53352. * The luminance threshold, pixels below this value will be set to black.
  53353. */
  53354. threshold: number;
  53355. /** @hidden */ private _exposure: number;
  53356. /**
  53357. * Post process which has the input texture to be used when performing highlight extraction
  53358. * @hidden
  53359. */ private _inputPostProcess: Nullable<PostProcess>;
  53360. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53361. }
  53362. }
  53363. declare module BABYLON {
  53364. /** @hidden */
  53365. export var bloomMergePixelShader: {
  53366. name: string;
  53367. shader: string;
  53368. };
  53369. }
  53370. declare module BABYLON {
  53371. /**
  53372. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53373. */
  53374. export class BloomMergePostProcess extends PostProcess {
  53375. /** Weight of the bloom to be added to the original input. */
  53376. weight: number;
  53377. /**
  53378. * Creates a new instance of @see BloomMergePostProcess
  53379. * @param name The name of the effect.
  53380. * @param originalFromInput Post process which's input will be used for the merge.
  53381. * @param blurred Blurred highlights post process which's output will be used.
  53382. * @param weight Weight of the bloom to be added to the original input.
  53383. * @param options The required width/height ratio to downsize to before computing the render pass.
  53384. * @param camera The camera to apply the render pass to.
  53385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53386. * @param engine The engine which the post process will be applied. (default: current engine)
  53387. * @param reusable If the post process can be reused on the same frame. (default: false)
  53388. * @param textureType Type of textures used when performing the post process. (default: 0)
  53389. * @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)
  53390. */
  53391. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53392. /** Weight of the bloom to be added to the original input. */
  53393. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53394. }
  53395. }
  53396. declare module BABYLON {
  53397. /**
  53398. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53399. */
  53400. export class BloomEffect extends PostProcessRenderEffect {
  53401. private bloomScale;
  53402. /**
  53403. * @hidden Internal
  53404. */ private _effects: Array<PostProcess>;
  53405. /**
  53406. * @hidden Internal
  53407. */ private _downscale: ExtractHighlightsPostProcess;
  53408. private _blurX;
  53409. private _blurY;
  53410. private _merge;
  53411. /**
  53412. * The luminance threshold to find bright areas of the image to bloom.
  53413. */
  53414. threshold: number;
  53415. /**
  53416. * The strength of the bloom.
  53417. */
  53418. weight: number;
  53419. /**
  53420. * Specifies the size of the bloom blur kernel, relative to the final output size
  53421. */
  53422. kernel: number;
  53423. /**
  53424. * Creates a new instance of @see BloomEffect
  53425. * @param scene The scene the effect belongs to.
  53426. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53427. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53428. * @param bloomWeight The the strength of bloom.
  53429. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53430. * @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)
  53431. */
  53432. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53433. /**
  53434. * Disposes each of the internal effects for a given camera.
  53435. * @param camera The camera to dispose the effect on.
  53436. */
  53437. disposeEffects(camera: Camera): void;
  53438. /**
  53439. * @hidden Internal
  53440. */ private _updateEffects(): void;
  53441. /**
  53442. * Internal
  53443. * @returns if all the contained post processes are ready.
  53444. * @hidden
  53445. */ private _isReady(): boolean;
  53446. }
  53447. }
  53448. declare module BABYLON {
  53449. /** @hidden */
  53450. export var chromaticAberrationPixelShader: {
  53451. name: string;
  53452. shader: string;
  53453. };
  53454. }
  53455. declare module BABYLON {
  53456. /**
  53457. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53458. */
  53459. export class ChromaticAberrationPostProcess extends PostProcess {
  53460. /**
  53461. * The amount of seperation of rgb channels (default: 30)
  53462. */
  53463. aberrationAmount: number;
  53464. /**
  53465. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53466. */
  53467. radialIntensity: number;
  53468. /**
  53469. * 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))
  53470. */
  53471. direction: Vector2;
  53472. /**
  53473. * 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))
  53474. */
  53475. centerPosition: Vector2;
  53476. /**
  53477. * Creates a new instance ChromaticAberrationPostProcess
  53478. * @param name The name of the effect.
  53479. * @param screenWidth The width of the screen to apply the effect on.
  53480. * @param screenHeight The height of the screen to apply the effect on.
  53481. * @param options The required width/height ratio to downsize to before computing the render pass.
  53482. * @param camera The camera to apply the render pass to.
  53483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53484. * @param engine The engine which the post process will be applied. (default: current engine)
  53485. * @param reusable If the post process can be reused on the same frame. (default: false)
  53486. * @param textureType Type of textures used when performing the post process. (default: 0)
  53487. * @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)
  53488. */
  53489. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53490. }
  53491. }
  53492. declare module BABYLON {
  53493. /** @hidden */
  53494. export var circleOfConfusionPixelShader: {
  53495. name: string;
  53496. shader: string;
  53497. };
  53498. }
  53499. declare module BABYLON {
  53500. /**
  53501. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53502. */
  53503. export class CircleOfConfusionPostProcess extends PostProcess {
  53504. /**
  53505. * 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.
  53506. */
  53507. lensSize: number;
  53508. /**
  53509. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53510. */
  53511. fStop: number;
  53512. /**
  53513. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53514. */
  53515. focusDistance: number;
  53516. /**
  53517. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53518. */
  53519. focalLength: number;
  53520. private _depthTexture;
  53521. /**
  53522. * Creates a new instance CircleOfConfusionPostProcess
  53523. * @param name The name of the effect.
  53524. * @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.
  53525. * @param options The required width/height ratio to downsize to before computing the render pass.
  53526. * @param camera The camera to apply the render pass to.
  53527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53528. * @param engine The engine which the post process will be applied. (default: current engine)
  53529. * @param reusable If the post process can be reused on the same frame. (default: false)
  53530. * @param textureType Type of textures used when performing the post process. (default: 0)
  53531. * @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)
  53532. */
  53533. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53534. /**
  53535. * 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.
  53536. */
  53537. depthTexture: RenderTargetTexture;
  53538. }
  53539. }
  53540. declare module BABYLON {
  53541. /** @hidden */
  53542. export var colorCorrectionPixelShader: {
  53543. name: string;
  53544. shader: string;
  53545. };
  53546. }
  53547. declare module BABYLON {
  53548. /**
  53549. *
  53550. * This post-process allows the modification of rendered colors by using
  53551. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53552. *
  53553. * The object needs to be provided an url to a texture containing the color
  53554. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53555. * Use an image editing software to tweak the LUT to match your needs.
  53556. *
  53557. * For an example of a color LUT, see here:
  53558. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53559. * For explanations on color grading, see here:
  53560. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53561. *
  53562. */
  53563. export class ColorCorrectionPostProcess extends PostProcess {
  53564. private _colorTableTexture;
  53565. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53566. }
  53567. }
  53568. declare module BABYLON {
  53569. /** @hidden */
  53570. export var convolutionPixelShader: {
  53571. name: string;
  53572. shader: string;
  53573. };
  53574. }
  53575. declare module BABYLON {
  53576. /**
  53577. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53578. * input texture to perform effects such as edge detection or sharpening
  53579. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53580. */
  53581. export class ConvolutionPostProcess extends PostProcess {
  53582. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53583. kernel: number[];
  53584. /**
  53585. * Creates a new instance ConvolutionPostProcess
  53586. * @param name The name of the effect.
  53587. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53588. * @param options The required width/height ratio to downsize to before computing the render pass.
  53589. * @param camera The camera to apply the render pass to.
  53590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53591. * @param engine The engine which the post process will be applied. (default: current engine)
  53592. * @param reusable If the post process can be reused on the same frame. (default: false)
  53593. * @param textureType Type of textures used when performing the post process. (default: 0)
  53594. */
  53595. constructor(name: string,
  53596. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53597. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53598. /**
  53599. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53600. */
  53601. static EdgeDetect0Kernel: number[];
  53602. /**
  53603. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53604. */
  53605. static EdgeDetect1Kernel: number[];
  53606. /**
  53607. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53608. */
  53609. static EdgeDetect2Kernel: number[];
  53610. /**
  53611. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53612. */
  53613. static SharpenKernel: number[];
  53614. /**
  53615. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53616. */
  53617. static EmbossKernel: number[];
  53618. /**
  53619. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53620. */
  53621. static GaussianKernel: number[];
  53622. }
  53623. }
  53624. declare module BABYLON {
  53625. /**
  53626. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53627. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53628. * based on samples that have a large difference in distance than the center pixel.
  53629. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53630. */
  53631. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53632. direction: Vector2;
  53633. /**
  53634. * Creates a new instance CircleOfConfusionPostProcess
  53635. * @param name The name of the effect.
  53636. * @param scene The scene the effect belongs to.
  53637. * @param direction The direction the blur should be applied.
  53638. * @param kernel The size of the kernel used to blur.
  53639. * @param options The required width/height ratio to downsize to before computing the render pass.
  53640. * @param camera The camera to apply the render pass to.
  53641. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53642. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53644. * @param engine The engine which the post process will be applied. (default: current engine)
  53645. * @param reusable If the post process can be reused on the same frame. (default: false)
  53646. * @param textureType Type of textures used when performing the post process. (default: 0)
  53647. * @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)
  53648. */
  53649. 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);
  53650. }
  53651. }
  53652. declare module BABYLON {
  53653. /** @hidden */
  53654. export var depthOfFieldMergePixelShader: {
  53655. name: string;
  53656. shader: string;
  53657. };
  53658. }
  53659. declare module BABYLON {
  53660. /**
  53661. * Options to be set when merging outputs from the default pipeline.
  53662. */
  53663. export class DepthOfFieldMergePostProcessOptions {
  53664. /**
  53665. * The original image to merge on top of
  53666. */
  53667. originalFromInput: PostProcess;
  53668. /**
  53669. * Parameters to perform the merge of the depth of field effect
  53670. */
  53671. depthOfField?: {
  53672. circleOfConfusion: PostProcess;
  53673. blurSteps: Array<PostProcess>;
  53674. };
  53675. /**
  53676. * Parameters to perform the merge of bloom effect
  53677. */
  53678. bloom?: {
  53679. blurred: PostProcess;
  53680. weight: number;
  53681. };
  53682. }
  53683. /**
  53684. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53685. */
  53686. export class DepthOfFieldMergePostProcess extends PostProcess {
  53687. private blurSteps;
  53688. /**
  53689. * Creates a new instance of DepthOfFieldMergePostProcess
  53690. * @param name The name of the effect.
  53691. * @param originalFromInput Post process which's input will be used for the merge.
  53692. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53693. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53694. * @param options The required width/height ratio to downsize to before computing the render pass.
  53695. * @param camera The camera to apply the render pass to.
  53696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53697. * @param engine The engine which the post process will be applied. (default: current engine)
  53698. * @param reusable If the post process can be reused on the same frame. (default: false)
  53699. * @param textureType Type of textures used when performing the post process. (default: 0)
  53700. * @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)
  53701. */
  53702. 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);
  53703. /**
  53704. * Updates the effect with the current post process compile time values and recompiles the shader.
  53705. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53706. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53707. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53708. * @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
  53709. * @param onCompiled Called when the shader has been compiled.
  53710. * @param onError Called if there is an error when compiling a shader.
  53711. */
  53712. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53713. }
  53714. }
  53715. declare module BABYLON {
  53716. /**
  53717. * Specifies the level of max blur that should be applied when using the depth of field effect
  53718. */
  53719. export enum DepthOfFieldEffectBlurLevel {
  53720. /**
  53721. * Subtle blur
  53722. */
  53723. Low = 0,
  53724. /**
  53725. * Medium blur
  53726. */
  53727. Medium = 1,
  53728. /**
  53729. * Large blur
  53730. */
  53731. High = 2
  53732. }
  53733. /**
  53734. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53735. */
  53736. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53737. private _circleOfConfusion;
  53738. /**
  53739. * @hidden Internal, blurs from high to low
  53740. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53741. private _depthOfFieldBlurY;
  53742. private _dofMerge;
  53743. /**
  53744. * @hidden Internal post processes in depth of field effect
  53745. */ private _effects: Array<PostProcess>;
  53746. /**
  53747. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53748. */
  53749. focalLength: number;
  53750. /**
  53751. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53752. */
  53753. fStop: number;
  53754. /**
  53755. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53756. */
  53757. focusDistance: number;
  53758. /**
  53759. * 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.
  53760. */
  53761. lensSize: number;
  53762. /**
  53763. * Creates a new instance DepthOfFieldEffect
  53764. * @param scene The scene the effect belongs to.
  53765. * @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.
  53766. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53767. * @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)
  53768. */
  53769. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53770. /**
  53771. * Get the current class name of the current effet
  53772. * @returns "DepthOfFieldEffect"
  53773. */
  53774. getClassName(): string;
  53775. /**
  53776. * 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.
  53777. */
  53778. depthTexture: RenderTargetTexture;
  53779. /**
  53780. * Disposes each of the internal effects for a given camera.
  53781. * @param camera The camera to dispose the effect on.
  53782. */
  53783. disposeEffects(camera: Camera): void;
  53784. /**
  53785. * @hidden Internal
  53786. */ private _updateEffects(): void;
  53787. /**
  53788. * Internal
  53789. * @returns if all the contained post processes are ready.
  53790. * @hidden
  53791. */ private _isReady(): boolean;
  53792. }
  53793. }
  53794. declare module BABYLON {
  53795. /** @hidden */
  53796. export var displayPassPixelShader: {
  53797. name: string;
  53798. shader: string;
  53799. };
  53800. }
  53801. declare module BABYLON {
  53802. /**
  53803. * DisplayPassPostProcess which produces an output the same as it's input
  53804. */
  53805. export class DisplayPassPostProcess extends PostProcess {
  53806. /**
  53807. * Creates the DisplayPassPostProcess
  53808. * @param name The name of the effect.
  53809. * @param options The required width/height ratio to downsize to before computing the render pass.
  53810. * @param camera The camera to apply the render pass to.
  53811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53812. * @param engine The engine which the post process will be applied. (default: current engine)
  53813. * @param reusable If the post process can be reused on the same frame. (default: false)
  53814. */
  53815. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53816. }
  53817. }
  53818. declare module BABYLON {
  53819. /** @hidden */
  53820. export var filterPixelShader: {
  53821. name: string;
  53822. shader: string;
  53823. };
  53824. }
  53825. declare module BABYLON {
  53826. /**
  53827. * Applies a kernel filter to the image
  53828. */
  53829. export class FilterPostProcess extends PostProcess {
  53830. /** The matrix to be applied to the image */
  53831. kernelMatrix: Matrix;
  53832. /**
  53833. *
  53834. * @param name The name of the effect.
  53835. * @param kernelMatrix The matrix to be applied to the image
  53836. * @param options The required width/height ratio to downsize to before computing the render pass.
  53837. * @param camera The camera to apply the render pass to.
  53838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53839. * @param engine The engine which the post process will be applied. (default: current engine)
  53840. * @param reusable If the post process can be reused on the same frame. (default: false)
  53841. */
  53842. constructor(name: string,
  53843. /** The matrix to be applied to the image */
  53844. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53845. }
  53846. }
  53847. declare module BABYLON {
  53848. /** @hidden */
  53849. export var fxaaPixelShader: {
  53850. name: string;
  53851. shader: string;
  53852. };
  53853. }
  53854. declare module BABYLON {
  53855. /** @hidden */
  53856. export var fxaaVertexShader: {
  53857. name: string;
  53858. shader: string;
  53859. };
  53860. }
  53861. declare module BABYLON {
  53862. /**
  53863. * Fxaa post process
  53864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53865. */
  53866. export class FxaaPostProcess extends PostProcess {
  53867. /** @hidden */
  53868. texelWidth: number;
  53869. /** @hidden */
  53870. texelHeight: number;
  53871. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53872. private _getDefines;
  53873. }
  53874. }
  53875. declare module BABYLON {
  53876. /** @hidden */
  53877. export var grainPixelShader: {
  53878. name: string;
  53879. shader: string;
  53880. };
  53881. }
  53882. declare module BABYLON {
  53883. /**
  53884. * The GrainPostProcess adds noise to the image at mid luminance levels
  53885. */
  53886. export class GrainPostProcess extends PostProcess {
  53887. /**
  53888. * The intensity of the grain added (default: 30)
  53889. */
  53890. intensity: number;
  53891. /**
  53892. * If the grain should be randomized on every frame
  53893. */
  53894. animated: boolean;
  53895. /**
  53896. * Creates a new instance of @see GrainPostProcess
  53897. * @param name The name of the effect.
  53898. * @param options The required width/height ratio to downsize to before computing the render pass.
  53899. * @param camera The camera to apply the render pass to.
  53900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53901. * @param engine The engine which the post process will be applied. (default: current engine)
  53902. * @param reusable If the post process can be reused on the same frame. (default: false)
  53903. * @param textureType Type of textures used when performing the post process. (default: 0)
  53904. * @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)
  53905. */
  53906. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53907. }
  53908. }
  53909. declare module BABYLON {
  53910. /** @hidden */
  53911. export var highlightsPixelShader: {
  53912. name: string;
  53913. shader: string;
  53914. };
  53915. }
  53916. declare module BABYLON {
  53917. /**
  53918. * Extracts highlights from the image
  53919. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53920. */
  53921. export class HighlightsPostProcess extends PostProcess {
  53922. /**
  53923. * Extracts highlights from the image
  53924. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53925. * @param name The name of the effect.
  53926. * @param options The required width/height ratio to downsize to before computing the render pass.
  53927. * @param camera The camera to apply the render pass to.
  53928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53929. * @param engine The engine which the post process will be applied. (default: current engine)
  53930. * @param reusable If the post process can be reused on the same frame. (default: false)
  53931. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53932. */
  53933. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53934. }
  53935. }
  53936. declare module BABYLON {
  53937. /** @hidden */
  53938. export var mrtFragmentDeclaration: {
  53939. name: string;
  53940. shader: string;
  53941. };
  53942. }
  53943. declare module BABYLON {
  53944. /** @hidden */
  53945. export var geometryPixelShader: {
  53946. name: string;
  53947. shader: string;
  53948. };
  53949. }
  53950. declare module BABYLON {
  53951. /** @hidden */
  53952. export var geometryVertexShader: {
  53953. name: string;
  53954. shader: string;
  53955. };
  53956. }
  53957. declare module BABYLON {
  53958. /** @hidden */
  53959. interface ISavedTransformationMatrix {
  53960. world: Matrix;
  53961. viewProjection: Matrix;
  53962. }
  53963. /**
  53964. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53965. */
  53966. export class GeometryBufferRenderer {
  53967. /**
  53968. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53969. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53970. */
  53971. static readonly POSITION_TEXTURE_TYPE: number;
  53972. /**
  53973. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53974. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53975. */
  53976. static readonly VELOCITY_TEXTURE_TYPE: number;
  53977. /**
  53978. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53979. * in order to compute objects velocities when enableVelocity is set to "true"
  53980. * @hidden
  53981. */ private _previousTransformationMatrices: {
  53982. [index: number]: ISavedTransformationMatrix;
  53983. };
  53984. /**
  53985. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  53986. * in order to compute objects velocities when enableVelocity is set to "true"
  53987. * @hidden
  53988. */ private _previousBonesTransformationMatrices: {
  53989. [index: number]: Float32Array;
  53990. };
  53991. /**
  53992. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  53993. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  53994. */
  53995. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  53996. private _scene;
  53997. private _multiRenderTarget;
  53998. private _ratio;
  53999. private _enablePosition;
  54000. private _enableVelocity;
  54001. private _positionIndex;
  54002. private _velocityIndex;
  54003. protected _effect: Effect;
  54004. protected _cachedDefines: string;
  54005. /**
  54006. * Set the render list (meshes to be rendered) used in the G buffer.
  54007. */
  54008. renderList: Mesh[];
  54009. /**
  54010. * Gets wether or not G buffer are supported by the running hardware.
  54011. * This requires draw buffer supports
  54012. */
  54013. readonly isSupported: boolean;
  54014. /**
  54015. * Returns the index of the given texture type in the G-Buffer textures array
  54016. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54017. * @returns the index of the given texture type in the G-Buffer textures array
  54018. */
  54019. getTextureIndex(textureType: number): number;
  54020. /**
  54021. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54022. */
  54023. /**
  54024. * Sets whether or not objects positions are enabled for the G buffer.
  54025. */
  54026. enablePosition: boolean;
  54027. /**
  54028. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54029. */
  54030. /**
  54031. * Sets wether or not objects velocities are enabled for the G buffer.
  54032. */
  54033. enableVelocity: boolean;
  54034. /**
  54035. * Gets the scene associated with the buffer.
  54036. */
  54037. readonly scene: Scene;
  54038. /**
  54039. * Gets the ratio used by the buffer during its creation.
  54040. * How big is the buffer related to the main canvas.
  54041. */
  54042. readonly ratio: number;
  54043. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  54044. /**
  54045. * Creates a new G Buffer for the scene
  54046. * @param scene The scene the buffer belongs to
  54047. * @param ratio How big is the buffer related to the main canvas.
  54048. */
  54049. constructor(scene: Scene, ratio?: number);
  54050. /**
  54051. * Checks wether everything is ready to render a submesh to the G buffer.
  54052. * @param subMesh the submesh to check readiness for
  54053. * @param useInstances is the mesh drawn using instance or not
  54054. * @returns true if ready otherwise false
  54055. */
  54056. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54057. /**
  54058. * Gets the current underlying G Buffer.
  54059. * @returns the buffer
  54060. */
  54061. getGBuffer(): MultiRenderTarget;
  54062. /**
  54063. * Gets the number of samples used to render the buffer (anti aliasing).
  54064. */
  54065. /**
  54066. * Sets the number of samples used to render the buffer (anti aliasing).
  54067. */
  54068. samples: number;
  54069. /**
  54070. * Disposes the renderer and frees up associated resources.
  54071. */
  54072. dispose(): void;
  54073. protected _createRenderTargets(): void;
  54074. private _copyBonesTransformationMatrices;
  54075. }
  54076. }
  54077. declare module BABYLON {
  54078. interface Scene {
  54079. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54080. /**
  54081. * Gets or Sets the current geometry buffer associated to the scene.
  54082. */
  54083. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54084. /**
  54085. * Enables a GeometryBufferRender and associates it with the scene
  54086. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54087. * @returns the GeometryBufferRenderer
  54088. */
  54089. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54090. /**
  54091. * Disables the GeometryBufferRender associated with the scene
  54092. */
  54093. disableGeometryBufferRenderer(): void;
  54094. }
  54095. /**
  54096. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54097. * in several rendering techniques.
  54098. */
  54099. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54100. /**
  54101. * The component name helpful to identify the component in the list of scene components.
  54102. */
  54103. readonly name: string;
  54104. /**
  54105. * The scene the component belongs to.
  54106. */
  54107. scene: Scene;
  54108. /**
  54109. * Creates a new instance of the component for the given scene
  54110. * @param scene Defines the scene to register the component in
  54111. */
  54112. constructor(scene: Scene);
  54113. /**
  54114. * Registers the component in a given scene
  54115. */
  54116. register(): void;
  54117. /**
  54118. * Rebuilds the elements related to this component in case of
  54119. * context lost for instance.
  54120. */
  54121. rebuild(): void;
  54122. /**
  54123. * Disposes the component and the associated ressources
  54124. */
  54125. dispose(): void;
  54126. private _gatherRenderTargets;
  54127. }
  54128. }
  54129. declare module BABYLON {
  54130. /** @hidden */
  54131. export var motionBlurPixelShader: {
  54132. name: string;
  54133. shader: string;
  54134. };
  54135. }
  54136. declare module BABYLON {
  54137. /**
  54138. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54139. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54140. * As an example, all you have to do is to create the post-process:
  54141. * var mb = new BABYLON.MotionBlurPostProcess(
  54142. * 'mb', // The name of the effect.
  54143. * scene, // The scene containing the objects to blur according to their velocity.
  54144. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54145. * camera // The camera to apply the render pass to.
  54146. * );
  54147. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54148. */
  54149. export class MotionBlurPostProcess extends PostProcess {
  54150. /**
  54151. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54152. */
  54153. motionStrength: number;
  54154. /**
  54155. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54156. */
  54157. /**
  54158. * Sets the number of iterations to be used for motion blur quality
  54159. */
  54160. motionBlurSamples: number;
  54161. private _motionBlurSamples;
  54162. private _geometryBufferRenderer;
  54163. /**
  54164. * Creates a new instance MotionBlurPostProcess
  54165. * @param name The name of the effect.
  54166. * @param scene The scene containing the objects to blur according to their velocity.
  54167. * @param options The required width/height ratio to downsize to before computing the render pass.
  54168. * @param camera The camera to apply the render pass to.
  54169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54170. * @param engine The engine which the post process will be applied. (default: current engine)
  54171. * @param reusable If the post process can be reused on the same frame. (default: false)
  54172. * @param textureType Type of textures used when performing the post process. (default: 0)
  54173. * @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)
  54174. */
  54175. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54176. /**
  54177. * Excludes the given skinned mesh from computing bones velocities.
  54178. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  54179. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  54180. */
  54181. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  54182. /**
  54183. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  54184. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  54185. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  54186. */
  54187. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  54188. /**
  54189. * Disposes the post process.
  54190. * @param camera The camera to dispose the post process on.
  54191. */
  54192. dispose(camera?: Camera): void;
  54193. }
  54194. }
  54195. declare module BABYLON {
  54196. /** @hidden */
  54197. export var refractionPixelShader: {
  54198. name: string;
  54199. shader: string;
  54200. };
  54201. }
  54202. declare module BABYLON {
  54203. /**
  54204. * Post process which applies a refractin texture
  54205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54206. */
  54207. export class RefractionPostProcess extends PostProcess {
  54208. /** the base color of the refraction (used to taint the rendering) */
  54209. color: Color3;
  54210. /** simulated refraction depth */
  54211. depth: number;
  54212. /** the coefficient of the base color (0 to remove base color tainting) */
  54213. colorLevel: number;
  54214. private _refTexture;
  54215. private _ownRefractionTexture;
  54216. /**
  54217. * Gets or sets the refraction texture
  54218. * Please note that you are responsible for disposing the texture if you set it manually
  54219. */
  54220. refractionTexture: Texture;
  54221. /**
  54222. * Initializes the RefractionPostProcess
  54223. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54224. * @param name The name of the effect.
  54225. * @param refractionTextureUrl Url of the refraction texture to use
  54226. * @param color the base color of the refraction (used to taint the rendering)
  54227. * @param depth simulated refraction depth
  54228. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54229. * @param camera The camera to apply the render pass to.
  54230. * @param options The required width/height ratio to downsize to before computing the render pass.
  54231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54232. * @param engine The engine which the post process will be applied. (default: current engine)
  54233. * @param reusable If the post process can be reused on the same frame. (default: false)
  54234. */
  54235. constructor(name: string, refractionTextureUrl: string,
  54236. /** the base color of the refraction (used to taint the rendering) */
  54237. color: Color3,
  54238. /** simulated refraction depth */
  54239. depth: number,
  54240. /** the coefficient of the base color (0 to remove base color tainting) */
  54241. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54242. /**
  54243. * Disposes of the post process
  54244. * @param camera Camera to dispose post process on
  54245. */
  54246. dispose(camera: Camera): void;
  54247. }
  54248. }
  54249. declare module BABYLON {
  54250. /** @hidden */
  54251. export var sharpenPixelShader: {
  54252. name: string;
  54253. shader: string;
  54254. };
  54255. }
  54256. declare module BABYLON {
  54257. /**
  54258. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54259. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54260. */
  54261. export class SharpenPostProcess extends PostProcess {
  54262. /**
  54263. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54264. */
  54265. colorAmount: number;
  54266. /**
  54267. * How much sharpness should be applied (default: 0.3)
  54268. */
  54269. edgeAmount: number;
  54270. /**
  54271. * Creates a new instance ConvolutionPostProcess
  54272. * @param name The name of the effect.
  54273. * @param options The required width/height ratio to downsize to before computing the render pass.
  54274. * @param camera The camera to apply the render pass to.
  54275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54276. * @param engine The engine which the post process will be applied. (default: current engine)
  54277. * @param reusable If the post process can be reused on the same frame. (default: false)
  54278. * @param textureType Type of textures used when performing the post process. (default: 0)
  54279. * @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)
  54280. */
  54281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54282. }
  54283. }
  54284. declare module BABYLON {
  54285. /**
  54286. * PostProcessRenderPipeline
  54287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54288. */
  54289. export class PostProcessRenderPipeline {
  54290. private engine;
  54291. private _renderEffects;
  54292. private _renderEffectsForIsolatedPass;
  54293. /**
  54294. * List of inspectable custom properties (used by the Inspector)
  54295. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54296. */
  54297. inspectableCustomProperties: IInspectable[];
  54298. /**
  54299. * @hidden
  54300. */
  54301. protected _cameras: Camera[];
  54302. /** @hidden */ private _name: string;
  54303. /**
  54304. * Gets pipeline name
  54305. */
  54306. readonly name: string;
  54307. /**
  54308. * Initializes a PostProcessRenderPipeline
  54309. * @param engine engine to add the pipeline to
  54310. * @param name name of the pipeline
  54311. */
  54312. constructor(engine: Engine, name: string);
  54313. /**
  54314. * Gets the class name
  54315. * @returns "PostProcessRenderPipeline"
  54316. */
  54317. getClassName(): string;
  54318. /**
  54319. * If all the render effects in the pipeline are supported
  54320. */
  54321. readonly isSupported: boolean;
  54322. /**
  54323. * Adds an effect to the pipeline
  54324. * @param renderEffect the effect to add
  54325. */
  54326. addEffect(renderEffect: PostProcessRenderEffect): void;
  54327. /** @hidden */ private _rebuild(): void;
  54328. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  54329. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54330. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54331. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54332. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  54333. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  54334. /** @hidden */ private _detachCameras(cameras: Camera): void;
  54335. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  54336. /** @hidden */ private _update(): void;
  54337. /** @hidden */ private _reset(): void;
  54338. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54339. /**
  54340. * Disposes of the pipeline
  54341. */
  54342. dispose(): void;
  54343. }
  54344. }
  54345. declare module BABYLON {
  54346. /**
  54347. * PostProcessRenderPipelineManager class
  54348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54349. */
  54350. export class PostProcessRenderPipelineManager {
  54351. private _renderPipelines;
  54352. /**
  54353. * Initializes a PostProcessRenderPipelineManager
  54354. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54355. */
  54356. constructor();
  54357. /**
  54358. * Gets the list of supported render pipelines
  54359. */
  54360. readonly supportedPipelines: PostProcessRenderPipeline[];
  54361. /**
  54362. * Adds a pipeline to the manager
  54363. * @param renderPipeline The pipeline to add
  54364. */
  54365. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54366. /**
  54367. * Attaches a camera to the pipeline
  54368. * @param renderPipelineName The name of the pipeline to attach to
  54369. * @param cameras the camera to attach
  54370. * @param unique if the camera can be attached multiple times to the pipeline
  54371. */
  54372. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54373. /**
  54374. * Detaches a camera from the pipeline
  54375. * @param renderPipelineName The name of the pipeline to detach from
  54376. * @param cameras the camera to detach
  54377. */
  54378. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54379. /**
  54380. * Enables an effect by name on a pipeline
  54381. * @param renderPipelineName the name of the pipeline to enable the effect in
  54382. * @param renderEffectName the name of the effect to enable
  54383. * @param cameras the cameras that the effect should be enabled on
  54384. */
  54385. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54386. /**
  54387. * Disables an effect by name on a pipeline
  54388. * @param renderPipelineName the name of the pipeline to disable the effect in
  54389. * @param renderEffectName the name of the effect to disable
  54390. * @param cameras the cameras that the effect should be disabled on
  54391. */
  54392. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54393. /**
  54394. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54395. */
  54396. update(): void;
  54397. /** @hidden */ private _rebuild(): void;
  54398. /**
  54399. * Disposes of the manager and pipelines
  54400. */
  54401. dispose(): void;
  54402. }
  54403. }
  54404. declare module BABYLON {
  54405. interface Scene {
  54406. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54407. /**
  54408. * Gets the postprocess render pipeline manager
  54409. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54410. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54411. */
  54412. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54413. }
  54414. /**
  54415. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54416. */
  54417. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54418. /**
  54419. * The component name helpfull to identify the component in the list of scene components.
  54420. */
  54421. readonly name: string;
  54422. /**
  54423. * The scene the component belongs to.
  54424. */
  54425. scene: Scene;
  54426. /**
  54427. * Creates a new instance of the component for the given scene
  54428. * @param scene Defines the scene to register the component in
  54429. */
  54430. constructor(scene: Scene);
  54431. /**
  54432. * Registers the component in a given scene
  54433. */
  54434. register(): void;
  54435. /**
  54436. * Rebuilds the elements related to this component in case of
  54437. * context lost for instance.
  54438. */
  54439. rebuild(): void;
  54440. /**
  54441. * Disposes the component and the associated ressources
  54442. */
  54443. dispose(): void;
  54444. private _gatherRenderTargets;
  54445. }
  54446. }
  54447. declare module BABYLON {
  54448. /**
  54449. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54450. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54451. */
  54452. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54453. private _scene;
  54454. private _camerasToBeAttached;
  54455. /**
  54456. * ID of the sharpen post process,
  54457. */
  54458. private readonly SharpenPostProcessId;
  54459. /**
  54460. * @ignore
  54461. * ID of the image processing post process;
  54462. */
  54463. readonly ImageProcessingPostProcessId: string;
  54464. /**
  54465. * @ignore
  54466. * ID of the Fast Approximate Anti-Aliasing post process;
  54467. */
  54468. readonly FxaaPostProcessId: string;
  54469. /**
  54470. * ID of the chromatic aberration post process,
  54471. */
  54472. private readonly ChromaticAberrationPostProcessId;
  54473. /**
  54474. * ID of the grain post process
  54475. */
  54476. private readonly GrainPostProcessId;
  54477. /**
  54478. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54479. */
  54480. sharpen: SharpenPostProcess;
  54481. private _sharpenEffect;
  54482. private bloom;
  54483. /**
  54484. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54485. */
  54486. depthOfField: DepthOfFieldEffect;
  54487. /**
  54488. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54489. */
  54490. fxaa: FxaaPostProcess;
  54491. /**
  54492. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54493. */
  54494. imageProcessing: ImageProcessingPostProcess;
  54495. /**
  54496. * Chromatic aberration post process which will shift rgb colors in the image
  54497. */
  54498. chromaticAberration: ChromaticAberrationPostProcess;
  54499. private _chromaticAberrationEffect;
  54500. /**
  54501. * Grain post process which add noise to the image
  54502. */
  54503. grain: GrainPostProcess;
  54504. private _grainEffect;
  54505. /**
  54506. * Glow post process which adds a glow to emissive areas of the image
  54507. */
  54508. private _glowLayer;
  54509. /**
  54510. * Animations which can be used to tweak settings over a period of time
  54511. */
  54512. animations: Animation[];
  54513. private _imageProcessingConfigurationObserver;
  54514. private _sharpenEnabled;
  54515. private _bloomEnabled;
  54516. private _depthOfFieldEnabled;
  54517. private _depthOfFieldBlurLevel;
  54518. private _fxaaEnabled;
  54519. private _imageProcessingEnabled;
  54520. private _defaultPipelineTextureType;
  54521. private _bloomScale;
  54522. private _chromaticAberrationEnabled;
  54523. private _grainEnabled;
  54524. private _buildAllowed;
  54525. /**
  54526. * Gets active scene
  54527. */
  54528. readonly scene: Scene;
  54529. /**
  54530. * Enable or disable the sharpen process from the pipeline
  54531. */
  54532. sharpenEnabled: boolean;
  54533. private _resizeObserver;
  54534. private _hardwareScaleLevel;
  54535. private _bloomKernel;
  54536. /**
  54537. * Specifies the size of the bloom blur kernel, relative to the final output size
  54538. */
  54539. bloomKernel: number;
  54540. /**
  54541. * Specifies the weight of the bloom in the final rendering
  54542. */
  54543. private _bloomWeight;
  54544. /**
  54545. * Specifies the luma threshold for the area that will be blurred by the bloom
  54546. */
  54547. private _bloomThreshold;
  54548. private _hdr;
  54549. /**
  54550. * The strength of the bloom.
  54551. */
  54552. bloomWeight: number;
  54553. /**
  54554. * The strength of the bloom.
  54555. */
  54556. bloomThreshold: number;
  54557. /**
  54558. * The scale of the bloom, lower value will provide better performance.
  54559. */
  54560. bloomScale: number;
  54561. /**
  54562. * Enable or disable the bloom from the pipeline
  54563. */
  54564. bloomEnabled: boolean;
  54565. private _rebuildBloom;
  54566. /**
  54567. * If the depth of field is enabled.
  54568. */
  54569. depthOfFieldEnabled: boolean;
  54570. /**
  54571. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54572. */
  54573. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54574. /**
  54575. * If the anti aliasing is enabled.
  54576. */
  54577. fxaaEnabled: boolean;
  54578. private _samples;
  54579. /**
  54580. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54581. */
  54582. samples: number;
  54583. /**
  54584. * If image processing is enabled.
  54585. */
  54586. imageProcessingEnabled: boolean;
  54587. /**
  54588. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54589. */
  54590. glowLayerEnabled: boolean;
  54591. /**
  54592. * Gets the glow layer (or null if not defined)
  54593. */
  54594. readonly glowLayer: Nullable<GlowLayer>;
  54595. /**
  54596. * Enable or disable the chromaticAberration process from the pipeline
  54597. */
  54598. chromaticAberrationEnabled: boolean;
  54599. /**
  54600. * Enable or disable the grain process from the pipeline
  54601. */
  54602. grainEnabled: boolean;
  54603. /**
  54604. * @constructor
  54605. * @param name - The rendering pipeline name (default: "")
  54606. * @param hdr - If high dynamic range textures should be used (default: true)
  54607. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54608. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54609. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54610. */
  54611. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54612. /**
  54613. * Get the class name
  54614. * @returns "DefaultRenderingPipeline"
  54615. */
  54616. getClassName(): string;
  54617. /**
  54618. * Force the compilation of the entire pipeline.
  54619. */
  54620. prepare(): void;
  54621. private _hasCleared;
  54622. private _prevPostProcess;
  54623. private _prevPrevPostProcess;
  54624. private _setAutoClearAndTextureSharing;
  54625. private _depthOfFieldSceneObserver;
  54626. private _buildPipeline;
  54627. private _disposePostProcesses;
  54628. /**
  54629. * Adds a camera to the pipeline
  54630. * @param camera the camera to be added
  54631. */
  54632. addCamera(camera: Camera): void;
  54633. /**
  54634. * Removes a camera from the pipeline
  54635. * @param camera the camera to remove
  54636. */
  54637. removeCamera(camera: Camera): void;
  54638. /**
  54639. * Dispose of the pipeline and stop all post processes
  54640. */
  54641. dispose(): void;
  54642. /**
  54643. * Serialize the rendering pipeline (Used when exporting)
  54644. * @returns the serialized object
  54645. */
  54646. serialize(): any;
  54647. /**
  54648. * Parse the serialized pipeline
  54649. * @param source Source pipeline.
  54650. * @param scene The scene to load the pipeline to.
  54651. * @param rootUrl The URL of the serialized pipeline.
  54652. * @returns An instantiated pipeline from the serialized object.
  54653. */
  54654. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54655. }
  54656. }
  54657. declare module BABYLON {
  54658. /** @hidden */
  54659. export var lensHighlightsPixelShader: {
  54660. name: string;
  54661. shader: string;
  54662. };
  54663. }
  54664. declare module BABYLON {
  54665. /** @hidden */
  54666. export var depthOfFieldPixelShader: {
  54667. name: string;
  54668. shader: string;
  54669. };
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * BABYLON.JS Chromatic Aberration GLSL Shader
  54674. * Author: Olivier Guyot
  54675. * Separates very slightly R, G and B colors on the edges of the screen
  54676. * Inspired by Francois Tarlier & Martins Upitis
  54677. */
  54678. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54679. /**
  54680. * @ignore
  54681. * The chromatic aberration PostProcess id in the pipeline
  54682. */
  54683. LensChromaticAberrationEffect: string;
  54684. /**
  54685. * @ignore
  54686. * The highlights enhancing PostProcess id in the pipeline
  54687. */
  54688. HighlightsEnhancingEffect: string;
  54689. /**
  54690. * @ignore
  54691. * The depth-of-field PostProcess id in the pipeline
  54692. */
  54693. LensDepthOfFieldEffect: string;
  54694. private _scene;
  54695. private _depthTexture;
  54696. private _grainTexture;
  54697. private _chromaticAberrationPostProcess;
  54698. private _highlightsPostProcess;
  54699. private _depthOfFieldPostProcess;
  54700. private _edgeBlur;
  54701. private _grainAmount;
  54702. private _chromaticAberration;
  54703. private _distortion;
  54704. private _highlightsGain;
  54705. private _highlightsThreshold;
  54706. private _dofDistance;
  54707. private _dofAperture;
  54708. private _dofDarken;
  54709. private _dofPentagon;
  54710. private _blurNoise;
  54711. /**
  54712. * @constructor
  54713. *
  54714. * Effect parameters are as follow:
  54715. * {
  54716. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54717. * edge_blur: number; // from 0 to x (1 for realism)
  54718. * distortion: number; // from 0 to x (1 for realism)
  54719. * grain_amount: number; // from 0 to 1
  54720. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54721. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54722. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54723. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54724. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54725. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54726. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54727. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54728. * }
  54729. * Note: if an effect parameter is unset, effect is disabled
  54730. *
  54731. * @param name The rendering pipeline name
  54732. * @param parameters - An object containing all parameters (see above)
  54733. * @param scene The scene linked to this pipeline
  54734. * @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)
  54735. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54736. */
  54737. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54738. /**
  54739. * Get the class name
  54740. * @returns "LensRenderingPipeline"
  54741. */
  54742. getClassName(): string;
  54743. /**
  54744. * Gets associated scene
  54745. */
  54746. readonly scene: Scene;
  54747. /**
  54748. * Gets or sets the edge blur
  54749. */
  54750. edgeBlur: number;
  54751. /**
  54752. * Gets or sets the grain amount
  54753. */
  54754. grainAmount: number;
  54755. /**
  54756. * Gets or sets the chromatic aberration amount
  54757. */
  54758. chromaticAberration: number;
  54759. /**
  54760. * Gets or sets the depth of field aperture
  54761. */
  54762. dofAperture: number;
  54763. /**
  54764. * Gets or sets the edge distortion
  54765. */
  54766. edgeDistortion: number;
  54767. /**
  54768. * Gets or sets the depth of field distortion
  54769. */
  54770. dofDistortion: number;
  54771. /**
  54772. * Gets or sets the darken out of focus amount
  54773. */
  54774. darkenOutOfFocus: number;
  54775. /**
  54776. * Gets or sets a boolean indicating if blur noise is enabled
  54777. */
  54778. blurNoise: boolean;
  54779. /**
  54780. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54781. */
  54782. pentagonBokeh: boolean;
  54783. /**
  54784. * Gets or sets the highlight grain amount
  54785. */
  54786. highlightsGain: number;
  54787. /**
  54788. * Gets or sets the highlight threshold
  54789. */
  54790. highlightsThreshold: number;
  54791. /**
  54792. * Sets the amount of blur at the edges
  54793. * @param amount blur amount
  54794. */
  54795. setEdgeBlur(amount: number): void;
  54796. /**
  54797. * Sets edge blur to 0
  54798. */
  54799. disableEdgeBlur(): void;
  54800. /**
  54801. * Sets the amout of grain
  54802. * @param amount Amount of grain
  54803. */
  54804. setGrainAmount(amount: number): void;
  54805. /**
  54806. * Set grain amount to 0
  54807. */
  54808. disableGrain(): void;
  54809. /**
  54810. * Sets the chromatic aberration amount
  54811. * @param amount amount of chromatic aberration
  54812. */
  54813. setChromaticAberration(amount: number): void;
  54814. /**
  54815. * Sets chromatic aberration amount to 0
  54816. */
  54817. disableChromaticAberration(): void;
  54818. /**
  54819. * Sets the EdgeDistortion amount
  54820. * @param amount amount of EdgeDistortion
  54821. */
  54822. setEdgeDistortion(amount: number): void;
  54823. /**
  54824. * Sets edge distortion to 0
  54825. */
  54826. disableEdgeDistortion(): void;
  54827. /**
  54828. * Sets the FocusDistance amount
  54829. * @param amount amount of FocusDistance
  54830. */
  54831. setFocusDistance(amount: number): void;
  54832. /**
  54833. * Disables depth of field
  54834. */
  54835. disableDepthOfField(): void;
  54836. /**
  54837. * Sets the Aperture amount
  54838. * @param amount amount of Aperture
  54839. */
  54840. setAperture(amount: number): void;
  54841. /**
  54842. * Sets the DarkenOutOfFocus amount
  54843. * @param amount amount of DarkenOutOfFocus
  54844. */
  54845. setDarkenOutOfFocus(amount: number): void;
  54846. private _pentagonBokehIsEnabled;
  54847. /**
  54848. * Creates a pentagon bokeh effect
  54849. */
  54850. enablePentagonBokeh(): void;
  54851. /**
  54852. * Disables the pentagon bokeh effect
  54853. */
  54854. disablePentagonBokeh(): void;
  54855. /**
  54856. * Enables noise blur
  54857. */
  54858. enableNoiseBlur(): void;
  54859. /**
  54860. * Disables noise blur
  54861. */
  54862. disableNoiseBlur(): void;
  54863. /**
  54864. * Sets the HighlightsGain amount
  54865. * @param amount amount of HighlightsGain
  54866. */
  54867. setHighlightsGain(amount: number): void;
  54868. /**
  54869. * Sets the HighlightsThreshold amount
  54870. * @param amount amount of HighlightsThreshold
  54871. */
  54872. setHighlightsThreshold(amount: number): void;
  54873. /**
  54874. * Disables highlights
  54875. */
  54876. disableHighlights(): void;
  54877. /**
  54878. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54879. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54880. */
  54881. dispose(disableDepthRender?: boolean): void;
  54882. private _createChromaticAberrationPostProcess;
  54883. private _createHighlightsPostProcess;
  54884. private _createDepthOfFieldPostProcess;
  54885. private _createGrainTexture;
  54886. }
  54887. }
  54888. declare module BABYLON {
  54889. /** @hidden */
  54890. export var ssao2PixelShader: {
  54891. name: string;
  54892. shader: string;
  54893. };
  54894. }
  54895. declare module BABYLON {
  54896. /** @hidden */
  54897. export var ssaoCombinePixelShader: {
  54898. name: string;
  54899. shader: string;
  54900. };
  54901. }
  54902. declare module BABYLON {
  54903. /**
  54904. * Render pipeline to produce ssao effect
  54905. */
  54906. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54907. /**
  54908. * @ignore
  54909. * The PassPostProcess id in the pipeline that contains the original scene color
  54910. */
  54911. SSAOOriginalSceneColorEffect: string;
  54912. /**
  54913. * @ignore
  54914. * The SSAO PostProcess id in the pipeline
  54915. */
  54916. SSAORenderEffect: string;
  54917. /**
  54918. * @ignore
  54919. * The horizontal blur PostProcess id in the pipeline
  54920. */
  54921. SSAOBlurHRenderEffect: string;
  54922. /**
  54923. * @ignore
  54924. * The vertical blur PostProcess id in the pipeline
  54925. */
  54926. SSAOBlurVRenderEffect: string;
  54927. /**
  54928. * @ignore
  54929. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54930. */
  54931. SSAOCombineRenderEffect: string;
  54932. /**
  54933. * The output strength of the SSAO post-process. Default value is 1.0.
  54934. */
  54935. totalStrength: number;
  54936. /**
  54937. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54938. */
  54939. maxZ: number;
  54940. /**
  54941. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54942. */
  54943. minZAspect: number;
  54944. private _samples;
  54945. /**
  54946. * Number of samples used for the SSAO calculations. Default value is 8
  54947. */
  54948. samples: number;
  54949. private _textureSamples;
  54950. /**
  54951. * Number of samples to use for antialiasing
  54952. */
  54953. textureSamples: number;
  54954. /**
  54955. * Ratio object used for SSAO ratio and blur ratio
  54956. */
  54957. private _ratio;
  54958. /**
  54959. * Dynamically generated sphere sampler.
  54960. */
  54961. private _sampleSphere;
  54962. /**
  54963. * Blur filter offsets
  54964. */
  54965. private _samplerOffsets;
  54966. private _expensiveBlur;
  54967. /**
  54968. * If bilateral blur should be used
  54969. */
  54970. expensiveBlur: boolean;
  54971. /**
  54972. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54973. */
  54974. radius: number;
  54975. /**
  54976. * The base color of the SSAO post-process
  54977. * The final result is "base + ssao" between [0, 1]
  54978. */
  54979. base: number;
  54980. /**
  54981. * Support test.
  54982. */
  54983. static readonly IsSupported: boolean;
  54984. private _scene;
  54985. private _depthTexture;
  54986. private _normalTexture;
  54987. private _randomTexture;
  54988. private _originalColorPostProcess;
  54989. private _ssaoPostProcess;
  54990. private _blurHPostProcess;
  54991. private _blurVPostProcess;
  54992. private _ssaoCombinePostProcess;
  54993. private _firstUpdate;
  54994. /**
  54995. * Gets active scene
  54996. */
  54997. readonly scene: Scene;
  54998. /**
  54999. * @constructor
  55000. * @param name The rendering pipeline name
  55001. * @param scene The scene linked to this pipeline
  55002. * @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 }
  55003. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55004. */
  55005. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55006. /**
  55007. * Get the class name
  55008. * @returns "SSAO2RenderingPipeline"
  55009. */
  55010. getClassName(): string;
  55011. /**
  55012. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55013. */
  55014. dispose(disableGeometryBufferRenderer?: boolean): void;
  55015. private _createBlurPostProcess;
  55016. /** @hidden */ private _rebuild(): void;
  55017. private _bits;
  55018. private _radicalInverse_VdC;
  55019. private _hammersley;
  55020. private _hemisphereSample_uniform;
  55021. private _generateHemisphere;
  55022. private _createSSAOPostProcess;
  55023. private _createSSAOCombinePostProcess;
  55024. private _createRandomTexture;
  55025. /**
  55026. * Serialize the rendering pipeline (Used when exporting)
  55027. * @returns the serialized object
  55028. */
  55029. serialize(): any;
  55030. /**
  55031. * Parse the serialized pipeline
  55032. * @param source Source pipeline.
  55033. * @param scene The scene to load the pipeline to.
  55034. * @param rootUrl The URL of the serialized pipeline.
  55035. * @returns An instantiated pipeline from the serialized object.
  55036. */
  55037. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55038. }
  55039. }
  55040. declare module BABYLON {
  55041. /** @hidden */
  55042. export var ssaoPixelShader: {
  55043. name: string;
  55044. shader: string;
  55045. };
  55046. }
  55047. declare module BABYLON {
  55048. /**
  55049. * Render pipeline to produce ssao effect
  55050. */
  55051. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55052. /**
  55053. * @ignore
  55054. * The PassPostProcess id in the pipeline that contains the original scene color
  55055. */
  55056. SSAOOriginalSceneColorEffect: string;
  55057. /**
  55058. * @ignore
  55059. * The SSAO PostProcess id in the pipeline
  55060. */
  55061. SSAORenderEffect: string;
  55062. /**
  55063. * @ignore
  55064. * The horizontal blur PostProcess id in the pipeline
  55065. */
  55066. SSAOBlurHRenderEffect: string;
  55067. /**
  55068. * @ignore
  55069. * The vertical blur PostProcess id in the pipeline
  55070. */
  55071. SSAOBlurVRenderEffect: string;
  55072. /**
  55073. * @ignore
  55074. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55075. */
  55076. SSAOCombineRenderEffect: string;
  55077. /**
  55078. * The output strength of the SSAO post-process. Default value is 1.0.
  55079. */
  55080. totalStrength: number;
  55081. /**
  55082. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55083. */
  55084. radius: number;
  55085. /**
  55086. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55087. * Must not be equal to fallOff and superior to fallOff.
  55088. * Default value is 0.0075
  55089. */
  55090. area: number;
  55091. /**
  55092. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55093. * Must not be equal to area and inferior to area.
  55094. * Default value is 0.000001
  55095. */
  55096. fallOff: number;
  55097. /**
  55098. * The base color of the SSAO post-process
  55099. * The final result is "base + ssao" between [0, 1]
  55100. */
  55101. base: number;
  55102. private _scene;
  55103. private _depthTexture;
  55104. private _randomTexture;
  55105. private _originalColorPostProcess;
  55106. private _ssaoPostProcess;
  55107. private _blurHPostProcess;
  55108. private _blurVPostProcess;
  55109. private _ssaoCombinePostProcess;
  55110. private _firstUpdate;
  55111. /**
  55112. * Gets active scene
  55113. */
  55114. readonly scene: Scene;
  55115. /**
  55116. * @constructor
  55117. * @param name - The rendering pipeline name
  55118. * @param scene - The scene linked to this pipeline
  55119. * @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 }
  55120. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55121. */
  55122. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55123. /**
  55124. * Get the class name
  55125. * @returns "SSAORenderingPipeline"
  55126. */
  55127. getClassName(): string;
  55128. /**
  55129. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55130. */
  55131. dispose(disableDepthRender?: boolean): void;
  55132. private _createBlurPostProcess;
  55133. /** @hidden */ private _rebuild(): void;
  55134. private _createSSAOPostProcess;
  55135. private _createSSAOCombinePostProcess;
  55136. private _createRandomTexture;
  55137. }
  55138. }
  55139. declare module BABYLON {
  55140. /** @hidden */
  55141. export var standardPixelShader: {
  55142. name: string;
  55143. shader: string;
  55144. };
  55145. }
  55146. declare module BABYLON {
  55147. /**
  55148. * Standard rendering pipeline
  55149. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55150. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55151. */
  55152. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55153. /**
  55154. * Public members
  55155. */
  55156. /**
  55157. * Post-process which contains the original scene color before the pipeline applies all the effects
  55158. */
  55159. originalPostProcess: Nullable<PostProcess>;
  55160. /**
  55161. * Post-process used to down scale an image x4
  55162. */
  55163. downSampleX4PostProcess: Nullable<PostProcess>;
  55164. /**
  55165. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55166. */
  55167. brightPassPostProcess: Nullable<PostProcess>;
  55168. /**
  55169. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55170. */
  55171. blurHPostProcesses: PostProcess[];
  55172. /**
  55173. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55174. */
  55175. blurVPostProcesses: PostProcess[];
  55176. /**
  55177. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55178. */
  55179. textureAdderPostProcess: Nullable<PostProcess>;
  55180. /**
  55181. * Post-process used to create volumetric lighting effect
  55182. */
  55183. volumetricLightPostProcess: Nullable<PostProcess>;
  55184. /**
  55185. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55186. */
  55187. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55188. /**
  55189. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55190. */
  55191. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55192. /**
  55193. * Post-process used to merge the volumetric light effect and the real scene color
  55194. */
  55195. volumetricLightMergePostProces: Nullable<PostProcess>;
  55196. /**
  55197. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55198. */
  55199. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55200. /**
  55201. * Base post-process used to calculate the average luminance of the final image for HDR
  55202. */
  55203. luminancePostProcess: Nullable<PostProcess>;
  55204. /**
  55205. * Post-processes used to create down sample post-processes in order to get
  55206. * the average luminance of the final image for HDR
  55207. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55208. */
  55209. luminanceDownSamplePostProcesses: PostProcess[];
  55210. /**
  55211. * Post-process used to create a HDR effect (light adaptation)
  55212. */
  55213. hdrPostProcess: Nullable<PostProcess>;
  55214. /**
  55215. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55216. */
  55217. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55218. /**
  55219. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55220. */
  55221. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55222. /**
  55223. * Post-process used to merge the final HDR post-process and the real scene color
  55224. */
  55225. hdrFinalPostProcess: Nullable<PostProcess>;
  55226. /**
  55227. * Post-process used to create a lens flare effect
  55228. */
  55229. lensFlarePostProcess: Nullable<PostProcess>;
  55230. /**
  55231. * Post-process that merges the result of the lens flare post-process and the real scene color
  55232. */
  55233. lensFlareComposePostProcess: Nullable<PostProcess>;
  55234. /**
  55235. * Post-process used to create a motion blur effect
  55236. */
  55237. motionBlurPostProcess: Nullable<PostProcess>;
  55238. /**
  55239. * Post-process used to create a depth of field effect
  55240. */
  55241. depthOfFieldPostProcess: Nullable<PostProcess>;
  55242. /**
  55243. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55244. */
  55245. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55246. /**
  55247. * Represents the brightness threshold in order to configure the illuminated surfaces
  55248. */
  55249. brightThreshold: number;
  55250. /**
  55251. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55252. */
  55253. blurWidth: number;
  55254. /**
  55255. * Sets if the blur for highlighted surfaces must be only horizontal
  55256. */
  55257. horizontalBlur: boolean;
  55258. /**
  55259. * Gets the overall exposure used by the pipeline
  55260. */
  55261. /**
  55262. * Sets the overall exposure used by the pipeline
  55263. */
  55264. exposure: number;
  55265. /**
  55266. * Texture used typically to simulate "dirty" on camera lens
  55267. */
  55268. lensTexture: Nullable<Texture>;
  55269. /**
  55270. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55271. */
  55272. volumetricLightCoefficient: number;
  55273. /**
  55274. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55275. */
  55276. volumetricLightPower: number;
  55277. /**
  55278. * Used the set the blur intensity to smooth the volumetric lights
  55279. */
  55280. volumetricLightBlurScale: number;
  55281. /**
  55282. * Light (spot or directional) used to generate the volumetric lights rays
  55283. * The source light must have a shadow generate so the pipeline can get its
  55284. * depth map
  55285. */
  55286. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55287. /**
  55288. * For eye adaptation, represents the minimum luminance the eye can see
  55289. */
  55290. hdrMinimumLuminance: number;
  55291. /**
  55292. * For eye adaptation, represents the decrease luminance speed
  55293. */
  55294. hdrDecreaseRate: number;
  55295. /**
  55296. * For eye adaptation, represents the increase luminance speed
  55297. */
  55298. hdrIncreaseRate: number;
  55299. /**
  55300. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  55301. */
  55302. /**
  55303. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  55304. */
  55305. hdrAutoExposure: boolean;
  55306. /**
  55307. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55308. */
  55309. lensColorTexture: Nullable<Texture>;
  55310. /**
  55311. * The overall strengh for the lens flare effect
  55312. */
  55313. lensFlareStrength: number;
  55314. /**
  55315. * Dispersion coefficient for lens flare ghosts
  55316. */
  55317. lensFlareGhostDispersal: number;
  55318. /**
  55319. * Main lens flare halo width
  55320. */
  55321. lensFlareHaloWidth: number;
  55322. /**
  55323. * Based on the lens distortion effect, defines how much the lens flare result
  55324. * is distorted
  55325. */
  55326. lensFlareDistortionStrength: number;
  55327. /**
  55328. * Lens star texture must be used to simulate rays on the flares and is available
  55329. * in the documentation
  55330. */
  55331. lensStarTexture: Nullable<Texture>;
  55332. /**
  55333. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55334. * flare effect by taking account of the dirt texture
  55335. */
  55336. lensFlareDirtTexture: Nullable<Texture>;
  55337. /**
  55338. * Represents the focal length for the depth of field effect
  55339. */
  55340. depthOfFieldDistance: number;
  55341. /**
  55342. * Represents the blur intensity for the blurred part of the depth of field effect
  55343. */
  55344. depthOfFieldBlurWidth: number;
  55345. /**
  55346. * Gets how much the image is blurred by the movement while using the motion blur post-process
  55347. */
  55348. /**
  55349. * Sets how much the image is blurred by the movement while using the motion blur post-process
  55350. */
  55351. motionStrength: number;
  55352. /**
  55353. * Gets wether or not the motion blur post-process is object based or screen based.
  55354. */
  55355. /**
  55356. * Sets wether or not the motion blur post-process should be object based or screen based
  55357. */
  55358. objectBasedMotionBlur: boolean;
  55359. /**
  55360. * List of animations for the pipeline (IAnimatable implementation)
  55361. */
  55362. animations: Animation[];
  55363. /**
  55364. * Private members
  55365. */
  55366. private _scene;
  55367. private _currentDepthOfFieldSource;
  55368. private _basePostProcess;
  55369. private _fixedExposure;
  55370. private _currentExposure;
  55371. private _hdrAutoExposure;
  55372. private _hdrCurrentLuminance;
  55373. private _motionStrength;
  55374. private _isObjectBasedMotionBlur;
  55375. private _floatTextureType;
  55376. private _ratio;
  55377. private _bloomEnabled;
  55378. private _depthOfFieldEnabled;
  55379. private _vlsEnabled;
  55380. private _lensFlareEnabled;
  55381. private _hdrEnabled;
  55382. private _motionBlurEnabled;
  55383. private _fxaaEnabled;
  55384. private _motionBlurSamples;
  55385. private _volumetricLightStepsCount;
  55386. private _samples;
  55387. /**
  55388. * @ignore
  55389. * Specifies if the bloom pipeline is enabled
  55390. */
  55391. BloomEnabled: boolean;
  55392. /**
  55393. * @ignore
  55394. * Specifies if the depth of field pipeline is enabed
  55395. */
  55396. DepthOfFieldEnabled: boolean;
  55397. /**
  55398. * @ignore
  55399. * Specifies if the lens flare pipeline is enabed
  55400. */
  55401. LensFlareEnabled: boolean;
  55402. /**
  55403. * @ignore
  55404. * Specifies if the HDR pipeline is enabled
  55405. */
  55406. HDREnabled: boolean;
  55407. /**
  55408. * @ignore
  55409. * Specifies if the volumetric lights scattering effect is enabled
  55410. */
  55411. VLSEnabled: boolean;
  55412. /**
  55413. * @ignore
  55414. * Specifies if the motion blur effect is enabled
  55415. */
  55416. MotionBlurEnabled: boolean;
  55417. /**
  55418. * Specifies if anti-aliasing is enabled
  55419. */
  55420. fxaaEnabled: boolean;
  55421. /**
  55422. * Specifies the number of steps used to calculate the volumetric lights
  55423. * Typically in interval [50, 200]
  55424. */
  55425. volumetricLightStepsCount: number;
  55426. /**
  55427. * Specifies the number of samples used for the motion blur effect
  55428. * Typically in interval [16, 64]
  55429. */
  55430. motionBlurSamples: number;
  55431. /**
  55432. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55433. */
  55434. samples: number;
  55435. /**
  55436. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55437. * @constructor
  55438. * @param name The rendering pipeline name
  55439. * @param scene The scene linked to this pipeline
  55440. * @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)
  55441. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55442. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55443. */
  55444. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55445. private _buildPipeline;
  55446. private _createDownSampleX4PostProcess;
  55447. private _createBrightPassPostProcess;
  55448. private _createBlurPostProcesses;
  55449. private _createTextureAdderPostProcess;
  55450. private _createVolumetricLightPostProcess;
  55451. private _createLuminancePostProcesses;
  55452. private _createHdrPostProcess;
  55453. private _createLensFlarePostProcess;
  55454. private _createDepthOfFieldPostProcess;
  55455. private _createMotionBlurPostProcess;
  55456. private _getDepthTexture;
  55457. private _disposePostProcesses;
  55458. /**
  55459. * Dispose of the pipeline and stop all post processes
  55460. */
  55461. dispose(): void;
  55462. /**
  55463. * Serialize the rendering pipeline (Used when exporting)
  55464. * @returns the serialized object
  55465. */
  55466. serialize(): any;
  55467. /**
  55468. * Parse the serialized pipeline
  55469. * @param source Source pipeline.
  55470. * @param scene The scene to load the pipeline to.
  55471. * @param rootUrl The URL of the serialized pipeline.
  55472. * @returns An instantiated pipeline from the serialized object.
  55473. */
  55474. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55475. /**
  55476. * Luminance steps
  55477. */
  55478. static LuminanceSteps: number;
  55479. }
  55480. }
  55481. declare module BABYLON {
  55482. /** @hidden */
  55483. export var tonemapPixelShader: {
  55484. name: string;
  55485. shader: string;
  55486. };
  55487. }
  55488. declare module BABYLON {
  55489. /** Defines operator used for tonemapping */
  55490. export enum TonemappingOperator {
  55491. /** Hable */
  55492. Hable = 0,
  55493. /** Reinhard */
  55494. Reinhard = 1,
  55495. /** HejiDawson */
  55496. HejiDawson = 2,
  55497. /** Photographic */
  55498. Photographic = 3
  55499. }
  55500. /**
  55501. * Defines a post process to apply tone mapping
  55502. */
  55503. export class TonemapPostProcess extends PostProcess {
  55504. private _operator;
  55505. /** Defines the required exposure adjustement */
  55506. exposureAdjustment: number;
  55507. /**
  55508. * Creates a new TonemapPostProcess
  55509. * @param name defines the name of the postprocess
  55510. * @param _operator defines the operator to use
  55511. * @param exposureAdjustment defines the required exposure adjustement
  55512. * @param camera defines the camera to use (can be null)
  55513. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55514. * @param engine defines the hosting engine (can be ignore if camera is set)
  55515. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55516. */
  55517. constructor(name: string, _operator: TonemappingOperator,
  55518. /** Defines the required exposure adjustement */
  55519. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55520. }
  55521. }
  55522. declare module BABYLON {
  55523. /** @hidden */
  55524. export var depthVertexShader: {
  55525. name: string;
  55526. shader: string;
  55527. };
  55528. }
  55529. declare module BABYLON {
  55530. /** @hidden */
  55531. export var volumetricLightScatteringPixelShader: {
  55532. name: string;
  55533. shader: string;
  55534. };
  55535. }
  55536. declare module BABYLON {
  55537. /** @hidden */
  55538. export var volumetricLightScatteringPassPixelShader: {
  55539. name: string;
  55540. shader: string;
  55541. };
  55542. }
  55543. declare module BABYLON {
  55544. /**
  55545. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55546. */
  55547. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55548. private _volumetricLightScatteringPass;
  55549. private _volumetricLightScatteringRTT;
  55550. private _viewPort;
  55551. private _screenCoordinates;
  55552. private _cachedDefines;
  55553. /**
  55554. * If not undefined, the mesh position is computed from the attached node position
  55555. */
  55556. attachedNode: {
  55557. position: Vector3;
  55558. };
  55559. /**
  55560. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55561. */
  55562. customMeshPosition: Vector3;
  55563. /**
  55564. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55565. */
  55566. useCustomMeshPosition: boolean;
  55567. /**
  55568. * If the post-process should inverse the light scattering direction
  55569. */
  55570. invert: boolean;
  55571. /**
  55572. * The internal mesh used by the post-process
  55573. */
  55574. mesh: Mesh;
  55575. /**
  55576. * @hidden
  55577. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55578. */
  55579. useDiffuseColor: boolean;
  55580. /**
  55581. * Array containing the excluded meshes not rendered in the internal pass
  55582. */
  55583. excludedMeshes: AbstractMesh[];
  55584. /**
  55585. * Controls the overall intensity of the post-process
  55586. */
  55587. exposure: number;
  55588. /**
  55589. * Dissipates each sample's contribution in range [0, 1]
  55590. */
  55591. decay: number;
  55592. /**
  55593. * Controls the overall intensity of each sample
  55594. */
  55595. weight: number;
  55596. /**
  55597. * Controls the density of each sample
  55598. */
  55599. density: number;
  55600. /**
  55601. * @constructor
  55602. * @param name The post-process name
  55603. * @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)
  55604. * @param camera The camera that the post-process will be attached to
  55605. * @param mesh The mesh used to create the light scattering
  55606. * @param samples The post-process quality, default 100
  55607. * @param samplingModeThe post-process filtering mode
  55608. * @param engine The babylon engine
  55609. * @param reusable If the post-process is reusable
  55610. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55611. */
  55612. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55613. /**
  55614. * Returns the string "VolumetricLightScatteringPostProcess"
  55615. * @returns "VolumetricLightScatteringPostProcess"
  55616. */
  55617. getClassName(): string;
  55618. private _isReady;
  55619. /**
  55620. * Sets the new light position for light scattering effect
  55621. * @param position The new custom light position
  55622. */
  55623. setCustomMeshPosition(position: Vector3): void;
  55624. /**
  55625. * Returns the light position for light scattering effect
  55626. * @return Vector3 The custom light position
  55627. */
  55628. getCustomMeshPosition(): Vector3;
  55629. /**
  55630. * Disposes the internal assets and detaches the post-process from the camera
  55631. */
  55632. dispose(camera: Camera): void;
  55633. /**
  55634. * Returns the render target texture used by the post-process
  55635. * @return the render target texture used by the post-process
  55636. */
  55637. getPass(): RenderTargetTexture;
  55638. private _meshExcluded;
  55639. private _createPass;
  55640. private _updateMeshScreenCoordinates;
  55641. /**
  55642. * Creates a default mesh for the Volumeric Light Scattering post-process
  55643. * @param name The mesh name
  55644. * @param scene The scene where to create the mesh
  55645. * @return the default mesh
  55646. */
  55647. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55648. }
  55649. }
  55650. declare module BABYLON {
  55651. interface Scene {
  55652. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  55653. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  55654. /**
  55655. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55656. */
  55657. forceShowBoundingBoxes: boolean;
  55658. /**
  55659. * Gets the bounding box renderer associated with the scene
  55660. * @returns a BoundingBoxRenderer
  55661. */
  55662. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55663. }
  55664. interface AbstractMesh {
  55665. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  55666. /**
  55667. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55668. */
  55669. showBoundingBox: boolean;
  55670. }
  55671. /**
  55672. * Component responsible of rendering the bounding box of the meshes in a scene.
  55673. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55674. */
  55675. export class BoundingBoxRenderer implements ISceneComponent {
  55676. /**
  55677. * The component name helpfull to identify the component in the list of scene components.
  55678. */
  55679. readonly name: string;
  55680. /**
  55681. * The scene the component belongs to.
  55682. */
  55683. scene: Scene;
  55684. /**
  55685. * Color of the bounding box lines placed in front of an object
  55686. */
  55687. frontColor: Color3;
  55688. /**
  55689. * Color of the bounding box lines placed behind an object
  55690. */
  55691. backColor: Color3;
  55692. /**
  55693. * Defines if the renderer should show the back lines or not
  55694. */
  55695. showBackLines: boolean;
  55696. /**
  55697. * @hidden
  55698. */
  55699. renderList: SmartArray<BoundingBox>;
  55700. private _colorShader;
  55701. private _vertexBuffers;
  55702. private _indexBuffer;
  55703. /**
  55704. * Instantiates a new bounding box renderer in a scene.
  55705. * @param scene the scene the renderer renders in
  55706. */
  55707. constructor(scene: Scene);
  55708. /**
  55709. * Registers the component in a given scene
  55710. */
  55711. register(): void;
  55712. private _evaluateSubMesh;
  55713. private _activeMesh;
  55714. private _prepareRessources;
  55715. private _createIndexBuffer;
  55716. /**
  55717. * Rebuilds the elements related to this component in case of
  55718. * context lost for instance.
  55719. */
  55720. rebuild(): void;
  55721. /**
  55722. * @hidden
  55723. */
  55724. reset(): void;
  55725. /**
  55726. * Render the bounding boxes of a specific rendering group
  55727. * @param renderingGroupId defines the rendering group to render
  55728. */
  55729. render(renderingGroupId: number): void;
  55730. /**
  55731. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55732. * @param mesh Define the mesh to render the occlusion bounding box for
  55733. */
  55734. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55735. /**
  55736. * Dispose and release the resources attached to this renderer.
  55737. */
  55738. dispose(): void;
  55739. }
  55740. }
  55741. declare module BABYLON {
  55742. /** @hidden */
  55743. export var depthPixelShader: {
  55744. name: string;
  55745. shader: string;
  55746. };
  55747. }
  55748. declare module BABYLON {
  55749. /**
  55750. * This represents a depth renderer in Babylon.
  55751. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55752. */
  55753. export class DepthRenderer {
  55754. private _scene;
  55755. private _depthMap;
  55756. private _effect;
  55757. private _cachedDefines;
  55758. private _camera;
  55759. /**
  55760. * Specifiess that the depth renderer will only be used within
  55761. * the camera it is created for.
  55762. * This can help forcing its rendering during the camera processing.
  55763. */
  55764. useOnlyInActiveCamera: boolean;
  55765. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  55766. /**
  55767. * Instantiates a depth renderer
  55768. * @param scene The scene the renderer belongs to
  55769. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55770. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55771. */
  55772. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55773. /**
  55774. * Creates the depth rendering effect and checks if the effect is ready.
  55775. * @param subMesh The submesh to be used to render the depth map of
  55776. * @param useInstances If multiple world instances should be used
  55777. * @returns if the depth renderer is ready to render the depth map
  55778. */
  55779. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55780. /**
  55781. * Gets the texture which the depth map will be written to.
  55782. * @returns The depth map texture
  55783. */
  55784. getDepthMap(): RenderTargetTexture;
  55785. /**
  55786. * Disposes of the depth renderer.
  55787. */
  55788. dispose(): void;
  55789. }
  55790. }
  55791. declare module BABYLON {
  55792. interface Scene {
  55793. /** @hidden (Backing field) */ private _depthRenderer: {
  55794. [id: string]: DepthRenderer;
  55795. };
  55796. /**
  55797. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55798. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55799. * @returns the created depth renderer
  55800. */
  55801. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55802. /**
  55803. * Disables a depth renderer for a given camera
  55804. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55805. */
  55806. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55807. }
  55808. /**
  55809. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55810. * in several rendering techniques.
  55811. */
  55812. export class DepthRendererSceneComponent implements ISceneComponent {
  55813. /**
  55814. * The component name helpfull to identify the component in the list of scene components.
  55815. */
  55816. readonly name: string;
  55817. /**
  55818. * The scene the component belongs to.
  55819. */
  55820. scene: Scene;
  55821. /**
  55822. * Creates a new instance of the component for the given scene
  55823. * @param scene Defines the scene to register the component in
  55824. */
  55825. constructor(scene: Scene);
  55826. /**
  55827. * Registers the component in a given scene
  55828. */
  55829. register(): void;
  55830. /**
  55831. * Rebuilds the elements related to this component in case of
  55832. * context lost for instance.
  55833. */
  55834. rebuild(): void;
  55835. /**
  55836. * Disposes the component and the associated ressources
  55837. */
  55838. dispose(): void;
  55839. private _gatherRenderTargets;
  55840. private _gatherActiveCameraRenderTargets;
  55841. }
  55842. }
  55843. declare module BABYLON {
  55844. /** @hidden */
  55845. export var outlinePixelShader: {
  55846. name: string;
  55847. shader: string;
  55848. };
  55849. }
  55850. declare module BABYLON {
  55851. /** @hidden */
  55852. export var outlineVertexShader: {
  55853. name: string;
  55854. shader: string;
  55855. };
  55856. }
  55857. declare module BABYLON {
  55858. interface Scene {
  55859. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  55860. /**
  55861. * Gets the outline renderer associated with the scene
  55862. * @returns a OutlineRenderer
  55863. */
  55864. getOutlineRenderer(): OutlineRenderer;
  55865. }
  55866. interface AbstractMesh {
  55867. /** @hidden (Backing field) */ private _renderOutline: boolean;
  55868. /**
  55869. * Gets or sets a boolean indicating if the outline must be rendered as well
  55870. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55871. */
  55872. renderOutline: boolean;
  55873. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  55874. /**
  55875. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55876. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55877. */
  55878. renderOverlay: boolean;
  55879. }
  55880. /**
  55881. * This class is responsible to draw bothe outline/overlay of meshes.
  55882. * It should not be used directly but through the available method on mesh.
  55883. */
  55884. export class OutlineRenderer implements ISceneComponent {
  55885. /**
  55886. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  55887. */
  55888. private static _StencilReference;
  55889. /**
  55890. * The name of the component. Each component must have a unique name.
  55891. */
  55892. name: string;
  55893. /**
  55894. * The scene the component belongs to.
  55895. */
  55896. scene: Scene;
  55897. /**
  55898. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55899. */
  55900. zOffset: number;
  55901. private _engine;
  55902. private _effect;
  55903. private _cachedDefines;
  55904. private _savedDepthWrite;
  55905. /**
  55906. * Instantiates a new outline renderer. (There could be only one per scene).
  55907. * @param scene Defines the scene it belongs to
  55908. */
  55909. constructor(scene: Scene);
  55910. /**
  55911. * Register the component to one instance of a scene.
  55912. */
  55913. register(): void;
  55914. /**
  55915. * Rebuilds the elements related to this component in case of
  55916. * context lost for instance.
  55917. */
  55918. rebuild(): void;
  55919. /**
  55920. * Disposes the component and the associated ressources.
  55921. */
  55922. dispose(): void;
  55923. /**
  55924. * Renders the outline in the canvas.
  55925. * @param subMesh Defines the sumesh to render
  55926. * @param batch Defines the batch of meshes in case of instances
  55927. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55928. */
  55929. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55930. /**
  55931. * Returns whether or not the outline renderer is ready for a given submesh.
  55932. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55933. * @param subMesh Defines the submesh to check readyness for
  55934. * @param useInstances Defines wheter wee are trying to render instances or not
  55935. * @returns true if ready otherwise false
  55936. */
  55937. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55938. private _beforeRenderingMesh;
  55939. private _afterRenderingMesh;
  55940. }
  55941. }
  55942. declare module BABYLON {
  55943. /**
  55944. * Defines the list of states available for a task inside a AssetsManager
  55945. */
  55946. export enum AssetTaskState {
  55947. /**
  55948. * Initialization
  55949. */
  55950. INIT = 0,
  55951. /**
  55952. * Running
  55953. */
  55954. RUNNING = 1,
  55955. /**
  55956. * Done
  55957. */
  55958. DONE = 2,
  55959. /**
  55960. * Error
  55961. */
  55962. ERROR = 3
  55963. }
  55964. /**
  55965. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55966. */
  55967. export abstract class AbstractAssetTask {
  55968. /**
  55969. * Task name
  55970. */ name: string;
  55971. /**
  55972. * Callback called when the task is successful
  55973. */
  55974. onSuccess: (task: any) => void;
  55975. /**
  55976. * Callback called when the task is not successful
  55977. */
  55978. onError: (task: any, message?: string, exception?: any) => void;
  55979. /**
  55980. * Creates a new AssetsManager
  55981. * @param name defines the name of the task
  55982. */
  55983. constructor(
  55984. /**
  55985. * Task name
  55986. */ name: string);
  55987. private _isCompleted;
  55988. private _taskState;
  55989. private _errorObject;
  55990. /**
  55991. * Get if the task is completed
  55992. */
  55993. readonly isCompleted: boolean;
  55994. /**
  55995. * Gets the current state of the task
  55996. */
  55997. readonly taskState: AssetTaskState;
  55998. /**
  55999. * Gets the current error object (if task is in error)
  56000. */
  56001. readonly errorObject: {
  56002. message?: string;
  56003. exception?: any;
  56004. };
  56005. /**
  56006. * Internal only
  56007. * @hidden
  56008. */ private _setErrorObject(message?: string, exception?: any): void;
  56009. /**
  56010. * Execute the current task
  56011. * @param scene defines the scene where you want your assets to be loaded
  56012. * @param onSuccess is a callback called when the task is successfully executed
  56013. * @param onError is a callback called if an error occurs
  56014. */
  56015. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56016. /**
  56017. * Execute the current task
  56018. * @param scene defines the scene where you want your assets to be loaded
  56019. * @param onSuccess is a callback called when the task is successfully executed
  56020. * @param onError is a callback called if an error occurs
  56021. */
  56022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56023. /**
  56024. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56025. * This can be used with failed tasks that have the reason for failure fixed.
  56026. */
  56027. reset(): void;
  56028. private onErrorCallback;
  56029. private onDoneCallback;
  56030. }
  56031. /**
  56032. * Define the interface used by progress events raised during assets loading
  56033. */
  56034. export interface IAssetsProgressEvent {
  56035. /**
  56036. * Defines the number of remaining tasks to process
  56037. */
  56038. remainingCount: number;
  56039. /**
  56040. * Defines the total number of tasks
  56041. */
  56042. totalCount: number;
  56043. /**
  56044. * Defines the task that was just processed
  56045. */
  56046. task: AbstractAssetTask;
  56047. }
  56048. /**
  56049. * Class used to share progress information about assets loading
  56050. */
  56051. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56052. /**
  56053. * Defines the number of remaining tasks to process
  56054. */
  56055. remainingCount: number;
  56056. /**
  56057. * Defines the total number of tasks
  56058. */
  56059. totalCount: number;
  56060. /**
  56061. * Defines the task that was just processed
  56062. */
  56063. task: AbstractAssetTask;
  56064. /**
  56065. * Creates a AssetsProgressEvent
  56066. * @param remainingCount defines the number of remaining tasks to process
  56067. * @param totalCount defines the total number of tasks
  56068. * @param task defines the task that was just processed
  56069. */
  56070. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56071. }
  56072. /**
  56073. * Define a task used by AssetsManager to load meshes
  56074. */
  56075. export class MeshAssetTask extends AbstractAssetTask {
  56076. /**
  56077. * Defines the name of the task
  56078. */
  56079. name: string;
  56080. /**
  56081. * Defines the list of mesh's names you want to load
  56082. */
  56083. meshesNames: any;
  56084. /**
  56085. * Defines the root url to use as a base to load your meshes and associated resources
  56086. */
  56087. rootUrl: string;
  56088. /**
  56089. * Defines the filename of the scene to load from
  56090. */
  56091. sceneFilename: string;
  56092. /**
  56093. * Gets the list of loaded meshes
  56094. */
  56095. loadedMeshes: Array<AbstractMesh>;
  56096. /**
  56097. * Gets the list of loaded particle systems
  56098. */
  56099. loadedParticleSystems: Array<IParticleSystem>;
  56100. /**
  56101. * Gets the list of loaded skeletons
  56102. */
  56103. loadedSkeletons: Array<Skeleton>;
  56104. /**
  56105. * Gets the list of loaded animation groups
  56106. */
  56107. loadedAnimationGroups: Array<AnimationGroup>;
  56108. /**
  56109. * Callback called when the task is successful
  56110. */
  56111. onSuccess: (task: MeshAssetTask) => void;
  56112. /**
  56113. * Callback called when the task is successful
  56114. */
  56115. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56116. /**
  56117. * Creates a new MeshAssetTask
  56118. * @param name defines the name of the task
  56119. * @param meshesNames defines the list of mesh's names you want to load
  56120. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56121. * @param sceneFilename defines the filename of the scene to load from
  56122. */
  56123. constructor(
  56124. /**
  56125. * Defines the name of the task
  56126. */
  56127. name: string,
  56128. /**
  56129. * Defines the list of mesh's names you want to load
  56130. */
  56131. meshesNames: any,
  56132. /**
  56133. * Defines the root url to use as a base to load your meshes and associated resources
  56134. */
  56135. rootUrl: string,
  56136. /**
  56137. * Defines the filename of the scene to load from
  56138. */
  56139. sceneFilename: string);
  56140. /**
  56141. * Execute the current task
  56142. * @param scene defines the scene where you want your assets to be loaded
  56143. * @param onSuccess is a callback called when the task is successfully executed
  56144. * @param onError is a callback called if an error occurs
  56145. */
  56146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56147. }
  56148. /**
  56149. * Define a task used by AssetsManager to load text content
  56150. */
  56151. export class TextFileAssetTask extends AbstractAssetTask {
  56152. /**
  56153. * Defines the name of the task
  56154. */
  56155. name: string;
  56156. /**
  56157. * Defines the location of the file to load
  56158. */
  56159. url: string;
  56160. /**
  56161. * Gets the loaded text string
  56162. */
  56163. text: string;
  56164. /**
  56165. * Callback called when the task is successful
  56166. */
  56167. onSuccess: (task: TextFileAssetTask) => void;
  56168. /**
  56169. * Callback called when the task is successful
  56170. */
  56171. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56172. /**
  56173. * Creates a new TextFileAssetTask object
  56174. * @param name defines the name of the task
  56175. * @param url defines the location of the file to load
  56176. */
  56177. constructor(
  56178. /**
  56179. * Defines the name of the task
  56180. */
  56181. name: string,
  56182. /**
  56183. * Defines the location of the file to load
  56184. */
  56185. url: string);
  56186. /**
  56187. * Execute the current task
  56188. * @param scene defines the scene where you want your assets to be loaded
  56189. * @param onSuccess is a callback called when the task is successfully executed
  56190. * @param onError is a callback called if an error occurs
  56191. */
  56192. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56193. }
  56194. /**
  56195. * Define a task used by AssetsManager to load binary data
  56196. */
  56197. export class BinaryFileAssetTask extends AbstractAssetTask {
  56198. /**
  56199. * Defines the name of the task
  56200. */
  56201. name: string;
  56202. /**
  56203. * Defines the location of the file to load
  56204. */
  56205. url: string;
  56206. /**
  56207. * Gets the lodaded data (as an array buffer)
  56208. */
  56209. data: ArrayBuffer;
  56210. /**
  56211. * Callback called when the task is successful
  56212. */
  56213. onSuccess: (task: BinaryFileAssetTask) => void;
  56214. /**
  56215. * Callback called when the task is successful
  56216. */
  56217. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56218. /**
  56219. * Creates a new BinaryFileAssetTask object
  56220. * @param name defines the name of the new task
  56221. * @param url defines the location of the file to load
  56222. */
  56223. constructor(
  56224. /**
  56225. * Defines the name of the task
  56226. */
  56227. name: string,
  56228. /**
  56229. * Defines the location of the file to load
  56230. */
  56231. url: string);
  56232. /**
  56233. * Execute the current task
  56234. * @param scene defines the scene where you want your assets to be loaded
  56235. * @param onSuccess is a callback called when the task is successfully executed
  56236. * @param onError is a callback called if an error occurs
  56237. */
  56238. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56239. }
  56240. /**
  56241. * Define a task used by AssetsManager to load images
  56242. */
  56243. export class ImageAssetTask extends AbstractAssetTask {
  56244. /**
  56245. * Defines the name of the task
  56246. */
  56247. name: string;
  56248. /**
  56249. * Defines the location of the image to load
  56250. */
  56251. url: string;
  56252. /**
  56253. * Gets the loaded images
  56254. */
  56255. image: HTMLImageElement;
  56256. /**
  56257. * Callback called when the task is successful
  56258. */
  56259. onSuccess: (task: ImageAssetTask) => void;
  56260. /**
  56261. * Callback called when the task is successful
  56262. */
  56263. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56264. /**
  56265. * Creates a new ImageAssetTask
  56266. * @param name defines the name of the task
  56267. * @param url defines the location of the image to load
  56268. */
  56269. constructor(
  56270. /**
  56271. * Defines the name of the task
  56272. */
  56273. name: string,
  56274. /**
  56275. * Defines the location of the image to load
  56276. */
  56277. url: string);
  56278. /**
  56279. * Execute the current task
  56280. * @param scene defines the scene where you want your assets to be loaded
  56281. * @param onSuccess is a callback called when the task is successfully executed
  56282. * @param onError is a callback called if an error occurs
  56283. */
  56284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56285. }
  56286. /**
  56287. * Defines the interface used by texture loading tasks
  56288. */
  56289. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56290. /**
  56291. * Gets the loaded texture
  56292. */
  56293. texture: TEX;
  56294. }
  56295. /**
  56296. * Define a task used by AssetsManager to load 2D textures
  56297. */
  56298. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56299. /**
  56300. * Defines the name of the task
  56301. */
  56302. name: string;
  56303. /**
  56304. * Defines the location of the file to load
  56305. */
  56306. url: string;
  56307. /**
  56308. * Defines if mipmap should not be generated (default is false)
  56309. */
  56310. noMipmap?: boolean | undefined;
  56311. /**
  56312. * Defines if texture must be inverted on Y axis (default is false)
  56313. */
  56314. invertY?: boolean | undefined;
  56315. /**
  56316. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56317. */
  56318. samplingMode: number;
  56319. /**
  56320. * Gets the loaded texture
  56321. */
  56322. texture: Texture;
  56323. /**
  56324. * Callback called when the task is successful
  56325. */
  56326. onSuccess: (task: TextureAssetTask) => void;
  56327. /**
  56328. * Callback called when the task is successful
  56329. */
  56330. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56331. /**
  56332. * Creates a new TextureAssetTask object
  56333. * @param name defines the name of the task
  56334. * @param url defines the location of the file to load
  56335. * @param noMipmap defines if mipmap should not be generated (default is false)
  56336. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56337. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56338. */
  56339. constructor(
  56340. /**
  56341. * Defines the name of the task
  56342. */
  56343. name: string,
  56344. /**
  56345. * Defines the location of the file to load
  56346. */
  56347. url: string,
  56348. /**
  56349. * Defines if mipmap should not be generated (default is false)
  56350. */
  56351. noMipmap?: boolean | undefined,
  56352. /**
  56353. * Defines if texture must be inverted on Y axis (default is false)
  56354. */
  56355. invertY?: boolean | undefined,
  56356. /**
  56357. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56358. */
  56359. samplingMode?: number);
  56360. /**
  56361. * Execute the current task
  56362. * @param scene defines the scene where you want your assets to be loaded
  56363. * @param onSuccess is a callback called when the task is successfully executed
  56364. * @param onError is a callback called if an error occurs
  56365. */
  56366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56367. }
  56368. /**
  56369. * Define a task used by AssetsManager to load cube textures
  56370. */
  56371. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56372. /**
  56373. * Defines the name of the task
  56374. */
  56375. name: string;
  56376. /**
  56377. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56378. */
  56379. url: string;
  56380. /**
  56381. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56382. */
  56383. extensions?: string[] | undefined;
  56384. /**
  56385. * Defines if mipmaps should not be generated (default is false)
  56386. */
  56387. noMipmap?: boolean | undefined;
  56388. /**
  56389. * Defines the explicit list of files (undefined by default)
  56390. */
  56391. files?: string[] | undefined;
  56392. /**
  56393. * Gets the loaded texture
  56394. */
  56395. texture: CubeTexture;
  56396. /**
  56397. * Callback called when the task is successful
  56398. */
  56399. onSuccess: (task: CubeTextureAssetTask) => void;
  56400. /**
  56401. * Callback called when the task is successful
  56402. */
  56403. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56404. /**
  56405. * Creates a new CubeTextureAssetTask
  56406. * @param name defines the name of the task
  56407. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56408. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56409. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56410. * @param files defines the explicit list of files (undefined by default)
  56411. */
  56412. constructor(
  56413. /**
  56414. * Defines the name of the task
  56415. */
  56416. name: string,
  56417. /**
  56418. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56419. */
  56420. url: string,
  56421. /**
  56422. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56423. */
  56424. extensions?: string[] | undefined,
  56425. /**
  56426. * Defines if mipmaps should not be generated (default is false)
  56427. */
  56428. noMipmap?: boolean | undefined,
  56429. /**
  56430. * Defines the explicit list of files (undefined by default)
  56431. */
  56432. files?: string[] | undefined);
  56433. /**
  56434. * Execute the current task
  56435. * @param scene defines the scene where you want your assets to be loaded
  56436. * @param onSuccess is a callback called when the task is successfully executed
  56437. * @param onError is a callback called if an error occurs
  56438. */
  56439. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56440. }
  56441. /**
  56442. * Define a task used by AssetsManager to load HDR cube textures
  56443. */
  56444. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56445. /**
  56446. * Defines the name of the task
  56447. */
  56448. name: string;
  56449. /**
  56450. * Defines the location of the file to load
  56451. */
  56452. url: string;
  56453. /**
  56454. * Defines the desired size (the more it increases the longer the generation will be)
  56455. */
  56456. size: number;
  56457. /**
  56458. * Defines if mipmaps should not be generated (default is false)
  56459. */
  56460. noMipmap: boolean;
  56461. /**
  56462. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56463. */
  56464. generateHarmonics: boolean;
  56465. /**
  56466. * 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)
  56467. */
  56468. gammaSpace: boolean;
  56469. /**
  56470. * Internal Use Only
  56471. */
  56472. reserved: boolean;
  56473. /**
  56474. * Gets the loaded texture
  56475. */
  56476. texture: HDRCubeTexture;
  56477. /**
  56478. * Callback called when the task is successful
  56479. */
  56480. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56481. /**
  56482. * Callback called when the task is successful
  56483. */
  56484. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56485. /**
  56486. * Creates a new HDRCubeTextureAssetTask object
  56487. * @param name defines the name of the task
  56488. * @param url defines the location of the file to load
  56489. * @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.
  56490. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56491. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56492. * @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)
  56493. * @param reserved Internal use only
  56494. */
  56495. constructor(
  56496. /**
  56497. * Defines the name of the task
  56498. */
  56499. name: string,
  56500. /**
  56501. * Defines the location of the file to load
  56502. */
  56503. url: string,
  56504. /**
  56505. * Defines the desired size (the more it increases the longer the generation will be)
  56506. */
  56507. size: number,
  56508. /**
  56509. * Defines if mipmaps should not be generated (default is false)
  56510. */
  56511. noMipmap?: boolean,
  56512. /**
  56513. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56514. */
  56515. generateHarmonics?: boolean,
  56516. /**
  56517. * 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)
  56518. */
  56519. gammaSpace?: boolean,
  56520. /**
  56521. * Internal Use Only
  56522. */
  56523. reserved?: boolean);
  56524. /**
  56525. * Execute the current task
  56526. * @param scene defines the scene where you want your assets to be loaded
  56527. * @param onSuccess is a callback called when the task is successfully executed
  56528. * @param onError is a callback called if an error occurs
  56529. */
  56530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56531. }
  56532. /**
  56533. * Define a task used by AssetsManager to load Equirectangular cube textures
  56534. */
  56535. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  56536. /**
  56537. * Defines the name of the task
  56538. */
  56539. name: string;
  56540. /**
  56541. * Defines the location of the file to load
  56542. */
  56543. url: string;
  56544. /**
  56545. * Defines the desired size (the more it increases the longer the generation will be)
  56546. */
  56547. size: number;
  56548. /**
  56549. * Defines if mipmaps should not be generated (default is false)
  56550. */
  56551. noMipmap: boolean;
  56552. /**
  56553. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  56554. * but the standard material would require them in Gamma space) (default is true)
  56555. */
  56556. gammaSpace: boolean;
  56557. /**
  56558. * Gets the loaded texture
  56559. */
  56560. texture: EquiRectangularCubeTexture;
  56561. /**
  56562. * Callback called when the task is successful
  56563. */
  56564. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  56565. /**
  56566. * Callback called when the task is successful
  56567. */
  56568. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  56569. /**
  56570. * Creates a new EquiRectangularCubeTextureAssetTask object
  56571. * @param name defines the name of the task
  56572. * @param url defines the location of the file to load
  56573. * @param size defines the desired size (the more it increases the longer the generation will be)
  56574. * If the size is omitted this implies you are using a preprocessed cubemap.
  56575. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56576. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  56577. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  56578. * (default is true)
  56579. */
  56580. constructor(
  56581. /**
  56582. * Defines the name of the task
  56583. */
  56584. name: string,
  56585. /**
  56586. * Defines the location of the file to load
  56587. */
  56588. url: string,
  56589. /**
  56590. * Defines the desired size (the more it increases the longer the generation will be)
  56591. */
  56592. size: number,
  56593. /**
  56594. * Defines if mipmaps should not be generated (default is false)
  56595. */
  56596. noMipmap?: boolean,
  56597. /**
  56598. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  56599. * but the standard material would require them in Gamma space) (default is true)
  56600. */
  56601. gammaSpace?: boolean);
  56602. /**
  56603. * Execute the current task
  56604. * @param scene defines the scene where you want your assets to be loaded
  56605. * @param onSuccess is a callback called when the task is successfully executed
  56606. * @param onError is a callback called if an error occurs
  56607. */
  56608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56609. }
  56610. /**
  56611. * This class can be used to easily import assets into a scene
  56612. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56613. */
  56614. export class AssetsManager {
  56615. private _scene;
  56616. private _isLoading;
  56617. protected _tasks: AbstractAssetTask[];
  56618. protected _waitingTasksCount: number;
  56619. protected _totalTasksCount: number;
  56620. /**
  56621. * Callback called when all tasks are processed
  56622. */
  56623. onFinish: (tasks: AbstractAssetTask[]) => void;
  56624. /**
  56625. * Callback called when a task is successful
  56626. */
  56627. onTaskSuccess: (task: AbstractAssetTask) => void;
  56628. /**
  56629. * Callback called when a task had an error
  56630. */
  56631. onTaskError: (task: AbstractAssetTask) => void;
  56632. /**
  56633. * Callback called when a task is done (whatever the result is)
  56634. */
  56635. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56636. /**
  56637. * Observable called when all tasks are processed
  56638. */
  56639. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56640. /**
  56641. * Observable called when a task had an error
  56642. */
  56643. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56644. /**
  56645. * Observable called when all tasks were executed
  56646. */
  56647. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56648. /**
  56649. * Observable called when a task is done (whatever the result is)
  56650. */
  56651. onProgressObservable: Observable<IAssetsProgressEvent>;
  56652. /**
  56653. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56655. */
  56656. useDefaultLoadingScreen: boolean;
  56657. /**
  56658. * Creates a new AssetsManager
  56659. * @param scene defines the scene to work on
  56660. */
  56661. constructor(scene: Scene);
  56662. /**
  56663. * Add a MeshAssetTask to the list of active tasks
  56664. * @param taskName defines the name of the new task
  56665. * @param meshesNames defines the name of meshes to load
  56666. * @param rootUrl defines the root url to use to locate files
  56667. * @param sceneFilename defines the filename of the scene file
  56668. * @returns a new MeshAssetTask object
  56669. */
  56670. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56671. /**
  56672. * Add a TextFileAssetTask to the list of active tasks
  56673. * @param taskName defines the name of the new task
  56674. * @param url defines the url of the file to load
  56675. * @returns a new TextFileAssetTask object
  56676. */
  56677. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56678. /**
  56679. * Add a BinaryFileAssetTask to the list of active tasks
  56680. * @param taskName defines the name of the new task
  56681. * @param url defines the url of the file to load
  56682. * @returns a new BinaryFileAssetTask object
  56683. */
  56684. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56685. /**
  56686. * Add a ImageAssetTask to the list of active tasks
  56687. * @param taskName defines the name of the new task
  56688. * @param url defines the url of the file to load
  56689. * @returns a new ImageAssetTask object
  56690. */
  56691. addImageTask(taskName: string, url: string): ImageAssetTask;
  56692. /**
  56693. * Add a TextureAssetTask to the list of active tasks
  56694. * @param taskName defines the name of the new task
  56695. * @param url defines the url of the file to load
  56696. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56697. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56698. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56699. * @returns a new TextureAssetTask object
  56700. */
  56701. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56702. /**
  56703. * Add a CubeTextureAssetTask to the list of active tasks
  56704. * @param taskName defines the name of the new task
  56705. * @param url defines the url of the file to load
  56706. * @param extensions defines the extension to use to load the cube map (can be null)
  56707. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56708. * @param files defines the list of files to load (can be null)
  56709. * @returns a new CubeTextureAssetTask object
  56710. */
  56711. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56712. /**
  56713. *
  56714. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56715. * @param taskName defines the name of the new task
  56716. * @param url defines the url of the file to load
  56717. * @param size defines the size you want for the cubemap (can be null)
  56718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56719. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56720. * @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)
  56721. * @param reserved Internal use only
  56722. * @returns a new HDRCubeTextureAssetTask object
  56723. */
  56724. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56725. /**
  56726. *
  56727. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  56728. * @param taskName defines the name of the new task
  56729. * @param url defines the url of the file to load
  56730. * @param size defines the size you want for the cubemap (can be null)
  56731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56732. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56733. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56734. * @returns a new EquiRectangularCubeTextureAssetTask object
  56735. */
  56736. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  56737. /**
  56738. * Remove a task from the assets manager.
  56739. * @param task the task to remove
  56740. */
  56741. removeTask(task: AbstractAssetTask): void;
  56742. private _decreaseWaitingTasksCount;
  56743. private _runTask;
  56744. /**
  56745. * Reset the AssetsManager and remove all tasks
  56746. * @return the current instance of the AssetsManager
  56747. */
  56748. reset(): AssetsManager;
  56749. /**
  56750. * Start the loading process
  56751. * @return the current instance of the AssetsManager
  56752. */
  56753. load(): AssetsManager;
  56754. /**
  56755. * Start the loading process as an async operation
  56756. * @return a promise returning the list of failed tasks
  56757. */
  56758. loadAsync(): Promise<void>;
  56759. }
  56760. }
  56761. declare module BABYLON {
  56762. /**
  56763. * Wrapper class for promise with external resolve and reject.
  56764. */
  56765. export class Deferred<T> {
  56766. /**
  56767. * The promise associated with this deferred object.
  56768. */
  56769. readonly promise: Promise<T>;
  56770. private _resolve;
  56771. private _reject;
  56772. /**
  56773. * The resolve method of the promise associated with this deferred object.
  56774. */
  56775. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56776. /**
  56777. * The reject method of the promise associated with this deferred object.
  56778. */
  56779. readonly reject: (reason?: any) => void;
  56780. /**
  56781. * Constructor for this deferred object.
  56782. */
  56783. constructor();
  56784. }
  56785. }
  56786. declare module BABYLON {
  56787. /**
  56788. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56789. */
  56790. export class MeshExploder {
  56791. private _centerMesh;
  56792. private _meshes;
  56793. private _meshesOrigins;
  56794. private _toCenterVectors;
  56795. private _scaledDirection;
  56796. private _newPosition;
  56797. private _centerPosition;
  56798. /**
  56799. * Explodes meshes from a center mesh.
  56800. * @param meshes The meshes to explode.
  56801. * @param centerMesh The mesh to be center of explosion.
  56802. */
  56803. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56804. private _setCenterMesh;
  56805. /**
  56806. * Get class name
  56807. * @returns "MeshExploder"
  56808. */
  56809. getClassName(): string;
  56810. /**
  56811. * "Exploded meshes"
  56812. * @returns Array of meshes with the centerMesh at index 0.
  56813. */
  56814. getMeshes(): Array<Mesh>;
  56815. /**
  56816. * Explodes meshes giving a specific direction
  56817. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56818. */
  56819. explode(direction?: number): void;
  56820. }
  56821. }
  56822. declare module BABYLON {
  56823. /**
  56824. * Class used to help managing file picking and drag'n'drop
  56825. */
  56826. export class FilesInput {
  56827. /**
  56828. * List of files ready to be loaded
  56829. */
  56830. static readonly FilesToLoad: {
  56831. [key: string]: File;
  56832. };
  56833. /**
  56834. * Callback called when a file is processed
  56835. */
  56836. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56837. private _engine;
  56838. private _currentScene;
  56839. private _sceneLoadedCallback;
  56840. private _progressCallback;
  56841. private _additionalRenderLoopLogicCallback;
  56842. private _textureLoadingCallback;
  56843. private _startingProcessingFilesCallback;
  56844. private _onReloadCallback;
  56845. private _errorCallback;
  56846. private _elementToMonitor;
  56847. private _sceneFileToLoad;
  56848. private _filesToLoad;
  56849. /**
  56850. * Creates a new FilesInput
  56851. * @param engine defines the rendering engine
  56852. * @param scene defines the hosting scene
  56853. * @param sceneLoadedCallback callback called when scene is loaded
  56854. * @param progressCallback callback called to track progress
  56855. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56856. * @param textureLoadingCallback callback called when a texture is loading
  56857. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56858. * @param onReloadCallback callback called when a reload is requested
  56859. * @param errorCallback callback call if an error occurs
  56860. */
  56861. 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);
  56862. private _dragEnterHandler;
  56863. private _dragOverHandler;
  56864. private _dropHandler;
  56865. /**
  56866. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56867. * @param elementToMonitor defines the DOM element to track
  56868. */
  56869. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56870. /**
  56871. * Release all associated resources
  56872. */
  56873. dispose(): void;
  56874. private renderFunction;
  56875. private drag;
  56876. private drop;
  56877. private _traverseFolder;
  56878. private _processFiles;
  56879. /**
  56880. * Load files from a drop event
  56881. * @param event defines the drop event to use as source
  56882. */
  56883. loadFiles(event: any): void;
  56884. private _processReload;
  56885. /**
  56886. * Reload the current scene from the loaded files
  56887. */
  56888. reload(): void;
  56889. }
  56890. }
  56891. declare module BABYLON {
  56892. /**
  56893. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56895. */
  56896. export class SceneOptimization {
  56897. /**
  56898. * Defines the priority of this optimization (0 by default which means first in the list)
  56899. */
  56900. priority: number;
  56901. /**
  56902. * Gets a string describing the action executed by the current optimization
  56903. * @returns description string
  56904. */
  56905. getDescription(): string;
  56906. /**
  56907. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56908. * @param scene defines the current scene where to apply this optimization
  56909. * @param optimizer defines the current optimizer
  56910. * @returns true if everything that can be done was applied
  56911. */
  56912. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56913. /**
  56914. * Creates the SceneOptimization object
  56915. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56916. * @param desc defines the description associated with the optimization
  56917. */
  56918. constructor(
  56919. /**
  56920. * Defines the priority of this optimization (0 by default which means first in the list)
  56921. */
  56922. priority?: number);
  56923. }
  56924. /**
  56925. * Defines an optimization used to reduce the size of render target textures
  56926. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56927. */
  56928. export class TextureOptimization extends SceneOptimization {
  56929. /**
  56930. * Defines the priority of this optimization (0 by default which means first in the list)
  56931. */
  56932. priority: number;
  56933. /**
  56934. * 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
  56935. */
  56936. maximumSize: number;
  56937. /**
  56938. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56939. */
  56940. step: number;
  56941. /**
  56942. * Gets a string describing the action executed by the current optimization
  56943. * @returns description string
  56944. */
  56945. getDescription(): string;
  56946. /**
  56947. * Creates the TextureOptimization object
  56948. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56949. * @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
  56950. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56951. */
  56952. constructor(
  56953. /**
  56954. * Defines the priority of this optimization (0 by default which means first in the list)
  56955. */
  56956. priority?: number,
  56957. /**
  56958. * 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
  56959. */
  56960. maximumSize?: number,
  56961. /**
  56962. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56963. */
  56964. step?: number);
  56965. /**
  56966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56967. * @param scene defines the current scene where to apply this optimization
  56968. * @param optimizer defines the current optimizer
  56969. * @returns true if everything that can be done was applied
  56970. */
  56971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56972. }
  56973. /**
  56974. * Defines an optimization used to increase or decrease the rendering resolution
  56975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56976. */
  56977. export class HardwareScalingOptimization extends SceneOptimization {
  56978. /**
  56979. * Defines the priority of this optimization (0 by default which means first in the list)
  56980. */
  56981. priority: number;
  56982. /**
  56983. * Defines the maximum scale to use (2 by default)
  56984. */
  56985. maximumScale: number;
  56986. /**
  56987. * Defines the step to use between two passes (0.5 by default)
  56988. */
  56989. step: number;
  56990. private _currentScale;
  56991. private _directionOffset;
  56992. /**
  56993. * Gets a string describing the action executed by the current optimization
  56994. * @return description string
  56995. */
  56996. getDescription(): string;
  56997. /**
  56998. * Creates the HardwareScalingOptimization object
  56999. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57000. * @param maximumScale defines the maximum scale to use (2 by default)
  57001. * @param step defines the step to use between two passes (0.5 by default)
  57002. */
  57003. constructor(
  57004. /**
  57005. * Defines the priority of this optimization (0 by default which means first in the list)
  57006. */
  57007. priority?: number,
  57008. /**
  57009. * Defines the maximum scale to use (2 by default)
  57010. */
  57011. maximumScale?: number,
  57012. /**
  57013. * Defines the step to use between two passes (0.5 by default)
  57014. */
  57015. step?: number);
  57016. /**
  57017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57018. * @param scene defines the current scene where to apply this optimization
  57019. * @param optimizer defines the current optimizer
  57020. * @returns true if everything that can be done was applied
  57021. */
  57022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57023. }
  57024. /**
  57025. * Defines an optimization used to remove shadows
  57026. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57027. */
  57028. export class ShadowsOptimization extends SceneOptimization {
  57029. /**
  57030. * Gets a string describing the action executed by the current optimization
  57031. * @return description string
  57032. */
  57033. getDescription(): string;
  57034. /**
  57035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57036. * @param scene defines the current scene where to apply this optimization
  57037. * @param optimizer defines the current optimizer
  57038. * @returns true if everything that can be done was applied
  57039. */
  57040. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57041. }
  57042. /**
  57043. * Defines an optimization used to turn post-processes off
  57044. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57045. */
  57046. export class PostProcessesOptimization extends SceneOptimization {
  57047. /**
  57048. * Gets a string describing the action executed by the current optimization
  57049. * @return description string
  57050. */
  57051. getDescription(): string;
  57052. /**
  57053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57054. * @param scene defines the current scene where to apply this optimization
  57055. * @param optimizer defines the current optimizer
  57056. * @returns true if everything that can be done was applied
  57057. */
  57058. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57059. }
  57060. /**
  57061. * Defines an optimization used to turn lens flares off
  57062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57063. */
  57064. export class LensFlaresOptimization extends SceneOptimization {
  57065. /**
  57066. * Gets a string describing the action executed by the current optimization
  57067. * @return description string
  57068. */
  57069. getDescription(): string;
  57070. /**
  57071. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57072. * @param scene defines the current scene where to apply this optimization
  57073. * @param optimizer defines the current optimizer
  57074. * @returns true if everything that can be done was applied
  57075. */
  57076. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57077. }
  57078. /**
  57079. * Defines an optimization based on user defined callback.
  57080. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57081. */
  57082. export class CustomOptimization extends SceneOptimization {
  57083. /**
  57084. * Callback called to apply the custom optimization.
  57085. */
  57086. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57087. /**
  57088. * Callback called to get custom description
  57089. */
  57090. onGetDescription: () => string;
  57091. /**
  57092. * Gets a string describing the action executed by the current optimization
  57093. * @returns description string
  57094. */
  57095. getDescription(): string;
  57096. /**
  57097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57098. * @param scene defines the current scene where to apply this optimization
  57099. * @param optimizer defines the current optimizer
  57100. * @returns true if everything that can be done was applied
  57101. */
  57102. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57103. }
  57104. /**
  57105. * Defines an optimization used to turn particles off
  57106. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57107. */
  57108. export class ParticlesOptimization extends SceneOptimization {
  57109. /**
  57110. * Gets a string describing the action executed by the current optimization
  57111. * @return description string
  57112. */
  57113. getDescription(): string;
  57114. /**
  57115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57116. * @param scene defines the current scene where to apply this optimization
  57117. * @param optimizer defines the current optimizer
  57118. * @returns true if everything that can be done was applied
  57119. */
  57120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57121. }
  57122. /**
  57123. * Defines an optimization used to turn render targets off
  57124. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57125. */
  57126. export class RenderTargetsOptimization extends SceneOptimization {
  57127. /**
  57128. * Gets a string describing the action executed by the current optimization
  57129. * @return description string
  57130. */
  57131. getDescription(): string;
  57132. /**
  57133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57134. * @param scene defines the current scene where to apply this optimization
  57135. * @param optimizer defines the current optimizer
  57136. * @returns true if everything that can be done was applied
  57137. */
  57138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57139. }
  57140. /**
  57141. * Defines an optimization used to merge meshes with compatible materials
  57142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57143. */
  57144. export class MergeMeshesOptimization extends SceneOptimization {
  57145. private static _UpdateSelectionTree;
  57146. /**
  57147. * Gets or sets a boolean which defines if optimization octree has to be updated
  57148. */
  57149. /**
  57150. * Gets or sets a boolean which defines if optimization octree has to be updated
  57151. */
  57152. static UpdateSelectionTree: boolean;
  57153. /**
  57154. * Gets a string describing the action executed by the current optimization
  57155. * @return description string
  57156. */
  57157. getDescription(): string;
  57158. private _canBeMerged;
  57159. /**
  57160. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57161. * @param scene defines the current scene where to apply this optimization
  57162. * @param optimizer defines the current optimizer
  57163. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57164. * @returns true if everything that can be done was applied
  57165. */
  57166. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57167. }
  57168. /**
  57169. * Defines a list of options used by SceneOptimizer
  57170. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57171. */
  57172. export class SceneOptimizerOptions {
  57173. /**
  57174. * Defines the target frame rate to reach (60 by default)
  57175. */
  57176. targetFrameRate: number;
  57177. /**
  57178. * Defines the interval between two checkes (2000ms by default)
  57179. */
  57180. trackerDuration: number;
  57181. /**
  57182. * Gets the list of optimizations to apply
  57183. */
  57184. optimizations: SceneOptimization[];
  57185. /**
  57186. * Creates a new list of options used by SceneOptimizer
  57187. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57188. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57189. */
  57190. constructor(
  57191. /**
  57192. * Defines the target frame rate to reach (60 by default)
  57193. */
  57194. targetFrameRate?: number,
  57195. /**
  57196. * Defines the interval between two checkes (2000ms by default)
  57197. */
  57198. trackerDuration?: number);
  57199. /**
  57200. * Add a new optimization
  57201. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57202. * @returns the current SceneOptimizerOptions
  57203. */
  57204. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57205. /**
  57206. * Add a new custom optimization
  57207. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57208. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57209. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57210. * @returns the current SceneOptimizerOptions
  57211. */
  57212. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57213. /**
  57214. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57215. * @param targetFrameRate defines the target frame rate (60 by default)
  57216. * @returns a SceneOptimizerOptions object
  57217. */
  57218. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57219. /**
  57220. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57221. * @param targetFrameRate defines the target frame rate (60 by default)
  57222. * @returns a SceneOptimizerOptions object
  57223. */
  57224. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57225. /**
  57226. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57227. * @param targetFrameRate defines the target frame rate (60 by default)
  57228. * @returns a SceneOptimizerOptions object
  57229. */
  57230. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57231. }
  57232. /**
  57233. * Class used to run optimizations in order to reach a target frame rate
  57234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57235. */
  57236. export class SceneOptimizer implements IDisposable {
  57237. private _isRunning;
  57238. private _options;
  57239. private _scene;
  57240. private _currentPriorityLevel;
  57241. private _targetFrameRate;
  57242. private _trackerDuration;
  57243. private _currentFrameRate;
  57244. private _sceneDisposeObserver;
  57245. private _improvementMode;
  57246. /**
  57247. * Defines an observable called when the optimizer reaches the target frame rate
  57248. */
  57249. onSuccessObservable: Observable<SceneOptimizer>;
  57250. /**
  57251. * Defines an observable called when the optimizer enables an optimization
  57252. */
  57253. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57254. /**
  57255. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57256. */
  57257. onFailureObservable: Observable<SceneOptimizer>;
  57258. /**
  57259. * Gets a boolean indicating if the optimizer is in improvement mode
  57260. */
  57261. readonly isInImprovementMode: boolean;
  57262. /**
  57263. * Gets the current priority level (0 at start)
  57264. */
  57265. readonly currentPriorityLevel: number;
  57266. /**
  57267. * Gets the current frame rate checked by the SceneOptimizer
  57268. */
  57269. readonly currentFrameRate: number;
  57270. /**
  57271. * Gets or sets the current target frame rate (60 by default)
  57272. */
  57273. /**
  57274. * Gets or sets the current target frame rate (60 by default)
  57275. */
  57276. targetFrameRate: number;
  57277. /**
  57278. * Gets or sets the current interval between two checks (every 2000ms by default)
  57279. */
  57280. /**
  57281. * Gets or sets the current interval between two checks (every 2000ms by default)
  57282. */
  57283. trackerDuration: number;
  57284. /**
  57285. * Gets the list of active optimizations
  57286. */
  57287. readonly optimizations: SceneOptimization[];
  57288. /**
  57289. * Creates a new SceneOptimizer
  57290. * @param scene defines the scene to work on
  57291. * @param options defines the options to use with the SceneOptimizer
  57292. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57293. * @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)
  57294. */
  57295. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57296. /**
  57297. * Stops the current optimizer
  57298. */
  57299. stop(): void;
  57300. /**
  57301. * Reset the optimizer to initial step (current priority level = 0)
  57302. */
  57303. reset(): void;
  57304. /**
  57305. * Start the optimizer. By default it will try to reach a specific framerate
  57306. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57307. */
  57308. start(): void;
  57309. private _checkCurrentState;
  57310. /**
  57311. * Release all resources
  57312. */
  57313. dispose(): void;
  57314. /**
  57315. * Helper function to create a SceneOptimizer with one single line of code
  57316. * @param scene defines the scene to work on
  57317. * @param options defines the options to use with the SceneOptimizer
  57318. * @param onSuccess defines a callback to call on success
  57319. * @param onFailure defines a callback to call on failure
  57320. * @returns the new SceneOptimizer object
  57321. */
  57322. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57323. }
  57324. }
  57325. declare module BABYLON {
  57326. /**
  57327. * Class used to serialize a scene into a string
  57328. */
  57329. export class SceneSerializer {
  57330. /**
  57331. * Clear cache used by a previous serialization
  57332. */
  57333. static ClearCache(): void;
  57334. /**
  57335. * Serialize a scene into a JSON compatible object
  57336. * @param scene defines the scene to serialize
  57337. * @returns a JSON compatible object
  57338. */
  57339. static Serialize(scene: Scene): any;
  57340. /**
  57341. * Serialize a mesh into a JSON compatible object
  57342. * @param toSerialize defines the mesh to serialize
  57343. * @param withParents defines if parents must be serialized as well
  57344. * @param withChildren defines if children must be serialized as well
  57345. * @returns a JSON compatible object
  57346. */
  57347. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57348. }
  57349. }
  57350. declare module BABYLON {
  57351. /**
  57352. * Class used to host texture specific utilities
  57353. */
  57354. export class TextureTools {
  57355. /**
  57356. * Uses the GPU to create a copy texture rescaled at a given size
  57357. * @param texture Texture to copy from
  57358. * @param width defines the desired width
  57359. * @param height defines the desired height
  57360. * @param useBilinearMode defines if bilinear mode has to be used
  57361. * @return the generated texture
  57362. */
  57363. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  57364. }
  57365. }
  57366. declare module BABYLON {
  57367. /**
  57368. * This represents the different options avilable for the video capture.
  57369. */
  57370. export interface VideoRecorderOptions {
  57371. /** Defines the mime type of the video */
  57372. mimeType: string;
  57373. /** Defines the video the video should be recorded at */
  57374. fps: number;
  57375. /** Defines the chunk size for the recording data */
  57376. recordChunckSize: number;
  57377. /** The audio tracks to attach to the record */
  57378. audioTracks?: MediaStreamTrack[];
  57379. }
  57380. /**
  57381. * This can helps recording videos from BabylonJS.
  57382. * This is based on the available WebRTC functionalities of the browser.
  57383. *
  57384. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57385. */
  57386. export class VideoRecorder {
  57387. private static readonly _defaultOptions;
  57388. /**
  57389. * Returns wehther or not the VideoRecorder is available in your browser.
  57390. * @param engine Defines the Babylon Engine to check the support for
  57391. * @returns true if supported otherwise false
  57392. */
  57393. static IsSupported(engine: Engine): boolean;
  57394. private readonly _options;
  57395. private _canvas;
  57396. private _mediaRecorder;
  57397. private _recordedChunks;
  57398. private _fileName;
  57399. private _resolve;
  57400. private _reject;
  57401. /**
  57402. * True wether a recording is already in progress.
  57403. */
  57404. readonly isRecording: boolean;
  57405. /**
  57406. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57407. * a video file.
  57408. * @param engine Defines the BabylonJS Engine you wish to record
  57409. * @param options Defines options that can be used to customized the capture
  57410. */
  57411. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57412. /**
  57413. * Stops the current recording before the default capture timeout passed in the startRecording
  57414. * functions.
  57415. */
  57416. stopRecording(): void;
  57417. /**
  57418. * Starts recording the canvas for a max duration specified in parameters.
  57419. * @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.
  57420. * @param maxDuration Defines the maximum recording time in seconds.
  57421. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57422. * @return a promise callback at the end of the recording with the video data in Blob.
  57423. */
  57424. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57425. /**
  57426. * Releases internal resources used during the recording.
  57427. */
  57428. dispose(): void;
  57429. private _handleDataAvailable;
  57430. private _handleError;
  57431. private _handleStop;
  57432. }
  57433. }
  57434. declare module BABYLON {
  57435. /**
  57436. * Class containing a set of static utilities functions for screenshots
  57437. */
  57438. export class ScreenshotTools {
  57439. /**
  57440. * Captures a screenshot of the current rendering
  57441. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57442. * @param engine defines the rendering engine
  57443. * @param camera defines the source camera
  57444. * @param size This parameter can be set to a single number or to an object with the
  57445. * following (optional) properties: precision, width, height. If a single number is passed,
  57446. * it will be used for both width and height. If an object is passed, the screenshot size
  57447. * will be derived from the parameters. The precision property is a multiplier allowing
  57448. * rendering at a higher or lower resolution
  57449. * @param successCallback defines the callback receives a single parameter which contains the
  57450. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57451. * src parameter of an <img> to display it
  57452. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57453. * Check your browser for supported MIME types
  57454. */
  57455. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57456. /**
  57457. * Generates an image screenshot from the specified camera.
  57458. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57459. * @param engine The engine to use for rendering
  57460. * @param camera The camera to use for rendering
  57461. * @param size This parameter can be set to a single number or to an object with the
  57462. * following (optional) properties: precision, width, height. If a single number is passed,
  57463. * it will be used for both width and height. If an object is passed, the screenshot size
  57464. * will be derived from the parameters. The precision property is a multiplier allowing
  57465. * rendering at a higher or lower resolution
  57466. * @param successCallback The callback receives a single parameter which contains the
  57467. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57468. * src parameter of an <img> to display it
  57469. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57470. * Check your browser for supported MIME types
  57471. * @param samples Texture samples (default: 1)
  57472. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57473. * @param fileName A name for for the downloaded file.
  57474. */
  57475. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57476. }
  57477. }
  57478. declare module BABYLON {
  57479. /**
  57480. * A cursor which tracks a point on a path
  57481. */
  57482. export class PathCursor {
  57483. private path;
  57484. /**
  57485. * Stores path cursor callbacks for when an onchange event is triggered
  57486. */
  57487. private _onchange;
  57488. /**
  57489. * The value of the path cursor
  57490. */
  57491. value: number;
  57492. /**
  57493. * The animation array of the path cursor
  57494. */
  57495. animations: Animation[];
  57496. /**
  57497. * Initializes the path cursor
  57498. * @param path The path to track
  57499. */
  57500. constructor(path: Path2);
  57501. /**
  57502. * Gets the cursor point on the path
  57503. * @returns A point on the path cursor at the cursor location
  57504. */
  57505. getPoint(): Vector3;
  57506. /**
  57507. * Moves the cursor ahead by the step amount
  57508. * @param step The amount to move the cursor forward
  57509. * @returns This path cursor
  57510. */
  57511. moveAhead(step?: number): PathCursor;
  57512. /**
  57513. * Moves the cursor behind by the step amount
  57514. * @param step The amount to move the cursor back
  57515. * @returns This path cursor
  57516. */
  57517. moveBack(step?: number): PathCursor;
  57518. /**
  57519. * Moves the cursor by the step amount
  57520. * If the step amount is greater than one, an exception is thrown
  57521. * @param step The amount to move the cursor
  57522. * @returns This path cursor
  57523. */
  57524. move(step: number): PathCursor;
  57525. /**
  57526. * Ensures that the value is limited between zero and one
  57527. * @returns This path cursor
  57528. */
  57529. private ensureLimits;
  57530. /**
  57531. * Runs onchange callbacks on change (used by the animation engine)
  57532. * @returns This path cursor
  57533. */
  57534. private raiseOnChange;
  57535. /**
  57536. * Executes a function on change
  57537. * @param f A path cursor onchange callback
  57538. * @returns This path cursor
  57539. */
  57540. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57541. }
  57542. }
  57543. declare module BABYLON {
  57544. /** @hidden */
  57545. export var blurPixelShader: {
  57546. name: string;
  57547. shader: string;
  57548. };
  57549. }
  57550. declare module BABYLON {
  57551. /** @hidden */
  57552. export var bones300Declaration: {
  57553. name: string;
  57554. shader: string;
  57555. };
  57556. }
  57557. declare module BABYLON {
  57558. /** @hidden */
  57559. export var instances300Declaration: {
  57560. name: string;
  57561. shader: string;
  57562. };
  57563. }
  57564. declare module BABYLON {
  57565. /** @hidden */
  57566. export var pointCloudVertexDeclaration: {
  57567. name: string;
  57568. shader: string;
  57569. };
  57570. }
  57571. // Mixins
  57572. interface Window {
  57573. mozIndexedDB: IDBFactory;
  57574. webkitIndexedDB: IDBFactory;
  57575. msIndexedDB: IDBFactory;
  57576. webkitURL: typeof URL;
  57577. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57578. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57579. WebGLRenderingContext: WebGLRenderingContext;
  57580. MSGesture: MSGesture;
  57581. CANNON: any;
  57582. AudioContext: AudioContext;
  57583. webkitAudioContext: AudioContext;
  57584. PointerEvent: any;
  57585. Math: Math;
  57586. Uint8Array: Uint8ArrayConstructor;
  57587. Float32Array: Float32ArrayConstructor;
  57588. mozURL: typeof URL;
  57589. msURL: typeof URL;
  57590. VRFrameData: any; // WebVR, from specs 1.1
  57591. DracoDecoderModule: any;
  57592. setImmediate(handler: (...args: any[]) => void): number;
  57593. }
  57594. interface HTMLCanvasElement {
  57595. requestPointerLock(): void;
  57596. msRequestPointerLock?(): void;
  57597. mozRequestPointerLock?(): void;
  57598. webkitRequestPointerLock?(): void;
  57599. /** Track wether a record is in progress */
  57600. isRecording: boolean;
  57601. /** Capture Stream method defined by some browsers */
  57602. captureStream(fps?: number): MediaStream;
  57603. }
  57604. interface CanvasRenderingContext2D {
  57605. msImageSmoothingEnabled: boolean;
  57606. }
  57607. interface MouseEvent {
  57608. mozMovementX: number;
  57609. mozMovementY: number;
  57610. webkitMovementX: number;
  57611. webkitMovementY: number;
  57612. msMovementX: number;
  57613. msMovementY: number;
  57614. }
  57615. interface Navigator {
  57616. mozGetVRDevices: (any: any) => any;
  57617. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57618. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57619. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57620. webkitGetGamepads(): Gamepad[];
  57621. msGetGamepads(): Gamepad[];
  57622. webkitGamepads(): Gamepad[];
  57623. }
  57624. interface HTMLVideoElement {
  57625. mozSrcObject: any;
  57626. }
  57627. interface Math {
  57628. fround(x: number): number;
  57629. imul(a: number, b: number): number;
  57630. }
  57631. interface WebGLRenderingContext {
  57632. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57633. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57634. vertexAttribDivisor(index: number, divisor: number): void;
  57635. createVertexArray(): any;
  57636. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57637. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57638. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57639. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57640. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57641. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57642. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57643. // Queries
  57644. createQuery(): WebGLQuery;
  57645. deleteQuery(query: WebGLQuery): void;
  57646. beginQuery(target: number, query: WebGLQuery): void;
  57647. endQuery(target: number): void;
  57648. getQueryParameter(query: WebGLQuery, pname: number): any;
  57649. getQuery(target: number, pname: number): any;
  57650. MAX_SAMPLES: number;
  57651. RGBA8: number;
  57652. READ_FRAMEBUFFER: number;
  57653. DRAW_FRAMEBUFFER: number;
  57654. UNIFORM_BUFFER: number;
  57655. HALF_FLOAT_OES: number;
  57656. RGBA16F: number;
  57657. RGBA32F: number;
  57658. R32F: number;
  57659. RG32F: number;
  57660. RGB32F: number;
  57661. R16F: number;
  57662. RG16F: number;
  57663. RGB16F: number;
  57664. RED: number;
  57665. RG: number;
  57666. R8: number;
  57667. RG8: number;
  57668. UNSIGNED_INT_24_8: number;
  57669. DEPTH24_STENCIL8: number;
  57670. /* Multiple Render Targets */
  57671. drawBuffers(buffers: number[]): void;
  57672. readBuffer(src: number): void;
  57673. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57674. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57675. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57676. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57677. // Occlusion Query
  57678. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57679. ANY_SAMPLES_PASSED: number;
  57680. QUERY_RESULT_AVAILABLE: number;
  57681. QUERY_RESULT: number;
  57682. }
  57683. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57684. }
  57685. interface EXT_disjoint_timer_query {
  57686. QUERY_COUNTER_BITS_EXT: number;
  57687. TIME_ELAPSED_EXT: number;
  57688. TIMESTAMP_EXT: number;
  57689. GPU_DISJOINT_EXT: number;
  57690. QUERY_RESULT_EXT: number;
  57691. QUERY_RESULT_AVAILABLE_EXT: number;
  57692. queryCounterEXT(query: WebGLQuery, target: number): void;
  57693. createQueryEXT(): WebGLQuery;
  57694. beginQueryEXT(target: number, query: WebGLQuery): void;
  57695. endQueryEXT(target: number): void;
  57696. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57697. deleteQueryEXT(query: WebGLQuery): void;
  57698. }
  57699. interface WebGLUniformLocation { private _currentState: any;
  57700. }
  57701. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57702. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57703. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57704. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57705. interface WebGLRenderingContext {
  57706. readonly RASTERIZER_DISCARD: number;
  57707. readonly DEPTH_COMPONENT24: number;
  57708. readonly TEXTURE_3D: number;
  57709. readonly TEXTURE_2D_ARRAY: number;
  57710. readonly TEXTURE_COMPARE_FUNC: number;
  57711. readonly TEXTURE_COMPARE_MODE: number;
  57712. readonly COMPARE_REF_TO_TEXTURE: number;
  57713. readonly TEXTURE_WRAP_R: number;
  57714. readonly HALF_FLOAT: number;
  57715. readonly RGB8: number;
  57716. readonly RED_INTEGER: number;
  57717. readonly RG_INTEGER: number;
  57718. readonly RGB_INTEGER: number;
  57719. readonly RGBA_INTEGER: number;
  57720. readonly R8_SNORM: number;
  57721. readonly RG8_SNORM: number;
  57722. readonly RGB8_SNORM: number;
  57723. readonly RGBA8_SNORM: number;
  57724. readonly R8I: number;
  57725. readonly RG8I: number;
  57726. readonly RGB8I: number;
  57727. readonly RGBA8I: number;
  57728. readonly R8UI: number;
  57729. readonly RG8UI: number;
  57730. readonly RGB8UI: number;
  57731. readonly RGBA8UI: number;
  57732. readonly R16I: number;
  57733. readonly RG16I: number;
  57734. readonly RGB16I: number;
  57735. readonly RGBA16I: number;
  57736. readonly R16UI: number;
  57737. readonly RG16UI: number;
  57738. readonly RGB16UI: number;
  57739. readonly RGBA16UI: number;
  57740. readonly R32I: number;
  57741. readonly RG32I: number;
  57742. readonly RGB32I: number;
  57743. readonly RGBA32I: number;
  57744. readonly R32UI: number;
  57745. readonly RG32UI: number;
  57746. readonly RGB32UI: number;
  57747. readonly RGBA32UI: number;
  57748. readonly RGB10_A2UI: number;
  57749. readonly R11F_G11F_B10F: number;
  57750. readonly RGB9_E5: number;
  57751. readonly RGB10_A2: number;
  57752. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57753. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57754. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57755. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57756. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57757. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57758. 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;
  57759. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57760. readonly TRANSFORM_FEEDBACK: number;
  57761. readonly INTERLEAVED_ATTRIBS: number;
  57762. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57763. createTransformFeedback(): WebGLTransformFeedback;
  57764. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57765. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57766. beginTransformFeedback(primitiveMode: number): void;
  57767. endTransformFeedback(): void;
  57768. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57769. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57770. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57771. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57772. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57773. }
  57774. interface ImageBitmap {
  57775. readonly width: number;
  57776. readonly height: number;
  57777. close(): void;
  57778. }
  57779. interface WebGLQuery extends WebGLObject {
  57780. }
  57781. declare var WebGLQuery: {
  57782. prototype: WebGLQuery;
  57783. new(): WebGLQuery;
  57784. };
  57785. interface WebGLSampler extends WebGLObject {
  57786. }
  57787. declare var WebGLSampler: {
  57788. prototype: WebGLSampler;
  57789. new(): WebGLSampler;
  57790. };
  57791. interface WebGLSync extends WebGLObject {
  57792. }
  57793. declare var WebGLSync: {
  57794. prototype: WebGLSync;
  57795. new(): WebGLSync;
  57796. };
  57797. interface WebGLTransformFeedback extends WebGLObject {
  57798. }
  57799. declare var WebGLTransformFeedback: {
  57800. prototype: WebGLTransformFeedback;
  57801. new(): WebGLTransformFeedback;
  57802. };
  57803. interface WebGLVertexArrayObject extends WebGLObject {
  57804. }
  57805. declare var WebGLVertexArrayObject: {
  57806. prototype: WebGLVertexArrayObject;
  57807. new(): WebGLVertexArrayObject;
  57808. };
  57809. // Type definitions for WebVR API
  57810. // Project: https://w3c.github.io/webvr/
  57811. // Definitions by: six a <https://github.com/lostfictions>
  57812. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57813. interface VRDisplay extends EventTarget {
  57814. /**
  57815. * Dictionary of capabilities describing the VRDisplay.
  57816. */
  57817. readonly capabilities: VRDisplayCapabilities;
  57818. /**
  57819. * z-depth defining the far plane of the eye view frustum
  57820. * enables mapping of values in the render target depth
  57821. * attachment to scene coordinates. Initially set to 10000.0.
  57822. */
  57823. depthFar: number;
  57824. /**
  57825. * z-depth defining the near plane of the eye view frustum
  57826. * enables mapping of values in the render target depth
  57827. * attachment to scene coordinates. Initially set to 0.01.
  57828. */
  57829. depthNear: number;
  57830. /**
  57831. * An identifier for this distinct VRDisplay. Used as an
  57832. * association point in the Gamepad API.
  57833. */
  57834. readonly displayId: number;
  57835. /**
  57836. * A display name, a user-readable name identifying it.
  57837. */
  57838. readonly displayName: string;
  57839. readonly isConnected: boolean;
  57840. readonly isPresenting: boolean;
  57841. /**
  57842. * If this VRDisplay supports room-scale experiences, the optional
  57843. * stage attribute contains details on the room-scale parameters.
  57844. */
  57845. readonly stageParameters: VRStageParameters | null;
  57846. /**
  57847. * Passing the value returned by `requestAnimationFrame` to
  57848. * `cancelAnimationFrame` will unregister the callback.
  57849. * @param handle Define the hanle of the request to cancel
  57850. */
  57851. cancelAnimationFrame(handle: number): void;
  57852. /**
  57853. * Stops presenting to the VRDisplay.
  57854. * @returns a promise to know when it stopped
  57855. */
  57856. exitPresent(): Promise<void>;
  57857. /**
  57858. * Return the current VREyeParameters for the given eye.
  57859. * @param whichEye Define the eye we want the parameter for
  57860. * @returns the eye parameters
  57861. */
  57862. getEyeParameters(whichEye: string): VREyeParameters;
  57863. /**
  57864. * Populates the passed VRFrameData with the information required to render
  57865. * the current frame.
  57866. * @param frameData Define the data structure to populate
  57867. * @returns true if ok otherwise false
  57868. */
  57869. getFrameData(frameData: VRFrameData): boolean;
  57870. /**
  57871. * Get the layers currently being presented.
  57872. * @returns the list of VR layers
  57873. */
  57874. getLayers(): VRLayer[];
  57875. /**
  57876. * Return a VRPose containing the future predicted pose of the VRDisplay
  57877. * when the current frame will be presented. The value returned will not
  57878. * change until JavaScript has returned control to the browser.
  57879. *
  57880. * The VRPose will contain the position, orientation, velocity,
  57881. * and acceleration of each of these properties.
  57882. * @returns the pose object
  57883. */
  57884. getPose(): VRPose;
  57885. /**
  57886. * Return the current instantaneous pose of the VRDisplay, with no
  57887. * prediction applied.
  57888. * @returns the current instantaneous pose
  57889. */
  57890. getImmediatePose(): VRPose;
  57891. /**
  57892. * The callback passed to `requestAnimationFrame` will be called
  57893. * any time a new frame should be rendered. When the VRDisplay is
  57894. * presenting the callback will be called at the native refresh
  57895. * rate of the HMD. When not presenting this function acts
  57896. * identically to how window.requestAnimationFrame acts. Content should
  57897. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57898. * asynchronously from other displays and at differing refresh rates.
  57899. * @param callback Define the eaction to run next frame
  57900. * @returns the request handle it
  57901. */
  57902. requestAnimationFrame(callback: FrameRequestCallback): number;
  57903. /**
  57904. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57905. * Repeat calls while already presenting will update the VRLayers being displayed.
  57906. * @param layers Define the list of layer to present
  57907. * @returns a promise to know when the request has been fulfilled
  57908. */
  57909. requestPresent(layers: VRLayer[]): Promise<void>;
  57910. /**
  57911. * Reset the pose for this display, treating its current position and
  57912. * orientation as the "origin/zero" values. VRPose.position,
  57913. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57914. * updated when calling resetPose(). This should be called in only
  57915. * sitting-space experiences.
  57916. */
  57917. resetPose(): void;
  57918. /**
  57919. * The VRLayer provided to the VRDisplay will be captured and presented
  57920. * in the HMD. Calling this function has the same effect on the source
  57921. * canvas as any other operation that uses its source image, and canvases
  57922. * created without preserveDrawingBuffer set to true will be cleared.
  57923. * @param pose Define the pose to submit
  57924. */
  57925. submitFrame(pose?: VRPose): void;
  57926. }
  57927. declare var VRDisplay: {
  57928. prototype: VRDisplay;
  57929. new(): VRDisplay;
  57930. };
  57931. interface VRLayer {
  57932. leftBounds?: number[] | Float32Array | null;
  57933. rightBounds?: number[] | Float32Array | null;
  57934. source?: HTMLCanvasElement | null;
  57935. }
  57936. interface VRDisplayCapabilities {
  57937. readonly canPresent: boolean;
  57938. readonly hasExternalDisplay: boolean;
  57939. readonly hasOrientation: boolean;
  57940. readonly hasPosition: boolean;
  57941. readonly maxLayers: number;
  57942. }
  57943. interface VREyeParameters {
  57944. /** @deprecated */
  57945. readonly fieldOfView: VRFieldOfView;
  57946. readonly offset: Float32Array;
  57947. readonly renderHeight: number;
  57948. readonly renderWidth: number;
  57949. }
  57950. interface VRFieldOfView {
  57951. readonly downDegrees: number;
  57952. readonly leftDegrees: number;
  57953. readonly rightDegrees: number;
  57954. readonly upDegrees: number;
  57955. }
  57956. interface VRFrameData {
  57957. readonly leftProjectionMatrix: Float32Array;
  57958. readonly leftViewMatrix: Float32Array;
  57959. readonly pose: VRPose;
  57960. readonly rightProjectionMatrix: Float32Array;
  57961. readonly rightViewMatrix: Float32Array;
  57962. readonly timestamp: number;
  57963. }
  57964. interface VRPose {
  57965. readonly angularAcceleration: Float32Array | null;
  57966. readonly angularVelocity: Float32Array | null;
  57967. readonly linearAcceleration: Float32Array | null;
  57968. readonly linearVelocity: Float32Array | null;
  57969. readonly orientation: Float32Array | null;
  57970. readonly position: Float32Array | null;
  57971. readonly timestamp: number;
  57972. }
  57973. interface VRStageParameters {
  57974. sittingToStandingTransform?: Float32Array;
  57975. sizeX?: number;
  57976. sizeY?: number;
  57977. }
  57978. interface Navigator {
  57979. getVRDisplays(): Promise<VRDisplay[]>;
  57980. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57981. }
  57982. interface Window {
  57983. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57984. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57985. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57986. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57987. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57988. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57989. }
  57990. interface Gamepad {
  57991. readonly displayId: number;
  57992. }
  57993. interface XRDevice {
  57994. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57995. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57996. }
  57997. interface XRSession {
  57998. getInputSources(): Array<any>;
  57999. baseLayer: XRWebGLLayer;
  58000. requestFrameOfReference(type: string): Promise<void>;
  58001. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58002. end(): Promise<void>;
  58003. requestAnimationFrame: Function;
  58004. addEventListener: Function;
  58005. }
  58006. interface XRSessionCreationOptions {
  58007. outputContext?: WebGLRenderingContext | null;
  58008. immersive?: boolean;
  58009. environmentIntegration?: boolean;
  58010. }
  58011. interface XRLayer {
  58012. getViewport: Function;
  58013. framebufferWidth: number;
  58014. framebufferHeight: number;
  58015. }
  58016. interface XRView {
  58017. projectionMatrix: Float32Array;
  58018. }
  58019. interface XRFrame {
  58020. getDevicePose: Function;
  58021. getInputPose: Function;
  58022. views: Array<XRView>;
  58023. baseLayer: XRLayer;
  58024. }
  58025. interface XRFrameOfReference {
  58026. }
  58027. interface XRWebGLLayer extends XRLayer {
  58028. framebuffer: WebGLFramebuffer;
  58029. }
  58030. declare var XRWebGLLayer: {
  58031. prototype: XRWebGLLayer;
  58032. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58033. };
  58034. declare module BABYLON.GUI {
  58035. /**
  58036. * Class used to specific a value and its associated unit
  58037. */
  58038. export class ValueAndUnit {
  58039. /** defines the unit to store */
  58040. unit: number;
  58041. /** defines a boolean indicating if the value can be negative */
  58042. negativeValueAllowed: boolean;
  58043. private _value;
  58044. private _originalUnit;
  58045. /**
  58046. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  58047. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58048. */
  58049. ignoreAdaptiveScaling: boolean;
  58050. /**
  58051. * Creates a new ValueAndUnit
  58052. * @param value defines the value to store
  58053. * @param unit defines the unit to store
  58054. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  58055. */
  58056. constructor(value: number,
  58057. /** defines the unit to store */
  58058. unit?: number,
  58059. /** defines a boolean indicating if the value can be negative */
  58060. negativeValueAllowed?: boolean);
  58061. /** Gets a boolean indicating if the value is a percentage */
  58062. readonly isPercentage: boolean;
  58063. /** Gets a boolean indicating if the value is store as pixel */
  58064. readonly isPixel: boolean;
  58065. /** Gets direct internal value */
  58066. readonly internalValue: number;
  58067. /**
  58068. * Gets value as pixel
  58069. * @param host defines the root host
  58070. * @param refValue defines the reference value for percentages
  58071. * @returns the value as pixel
  58072. */
  58073. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  58074. /**
  58075. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  58076. * @param value defines the value to store
  58077. * @param unit defines the unit to store
  58078. * @returns the current ValueAndUnit
  58079. */
  58080. updateInPlace(value: number, unit?: number): ValueAndUnit;
  58081. /**
  58082. * Gets the value accordingly to its unit
  58083. * @param host defines the root host
  58084. * @returns the value
  58085. */
  58086. getValue(host: AdvancedDynamicTexture): number;
  58087. /**
  58088. * Gets a string representation of the value
  58089. * @param host defines the root host
  58090. * @param decimals defines an optional number of decimals to display
  58091. * @returns a string
  58092. */
  58093. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  58094. /**
  58095. * Store a value parsed from a string
  58096. * @param source defines the source string
  58097. * @returns true if the value was successfully parsed
  58098. */
  58099. fromString(source: string | number): boolean;
  58100. private static _Regex;
  58101. private static _UNITMODE_PERCENTAGE;
  58102. private static _UNITMODE_PIXEL;
  58103. /** UNITMODE_PERCENTAGE */
  58104. static readonly UNITMODE_PERCENTAGE: number;
  58105. /** UNITMODE_PIXEL */
  58106. static readonly UNITMODE_PIXEL: number;
  58107. }
  58108. }
  58109. declare module BABYLON.GUI {
  58110. /**
  58111. * Define a style used by control to automatically setup properties based on a template.
  58112. * Only support font related properties so far
  58113. */
  58114. export class Style implements BABYLON.IDisposable {
  58115. private _fontFamily;
  58116. private _fontStyle;
  58117. private _fontWeight;
  58118. /** @hidden */ private _host: AdvancedDynamicTexture;
  58119. /** @hidden */ private _fontSize: ValueAndUnit;
  58120. /**
  58121. * BABYLON.Observable raised when the style values are changed
  58122. */
  58123. onChangedObservable: BABYLON.Observable<Style>;
  58124. /**
  58125. * Creates a new style object
  58126. * @param host defines the AdvancedDynamicTexture which hosts this style
  58127. */
  58128. constructor(host: AdvancedDynamicTexture);
  58129. /**
  58130. * Gets or sets the font size
  58131. */
  58132. fontSize: string | number;
  58133. /**
  58134. * Gets or sets the font family
  58135. */
  58136. fontFamily: string;
  58137. /**
  58138. * Gets or sets the font style
  58139. */
  58140. fontStyle: string;
  58141. /** Gets or sets font weight */
  58142. fontWeight: string;
  58143. /** Dispose all associated resources */
  58144. dispose(): void;
  58145. }
  58146. }
  58147. declare module BABYLON.GUI {
  58148. /**
  58149. * Class used to transport BABYLON.Vector2 information for pointer events
  58150. */
  58151. export class Vector2WithInfo extends BABYLON.Vector2 {
  58152. /** defines the current mouse button index */
  58153. buttonIndex: number;
  58154. /**
  58155. * Creates a new Vector2WithInfo
  58156. * @param source defines the vector2 data to transport
  58157. * @param buttonIndex defines the current mouse button index
  58158. */
  58159. constructor(source: BABYLON.Vector2,
  58160. /** defines the current mouse button index */
  58161. buttonIndex?: number);
  58162. }
  58163. /** Class used to provide 2D matrix features */
  58164. export class Matrix2D {
  58165. /** Gets the internal array of 6 floats used to store matrix data */
  58166. m: Float32Array;
  58167. /**
  58168. * Creates a new matrix
  58169. * @param m00 defines value for (0, 0)
  58170. * @param m01 defines value for (0, 1)
  58171. * @param m10 defines value for (1, 0)
  58172. * @param m11 defines value for (1, 1)
  58173. * @param m20 defines value for (2, 0)
  58174. * @param m21 defines value for (2, 1)
  58175. */
  58176. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  58177. /**
  58178. * Fills the matrix from direct values
  58179. * @param m00 defines value for (0, 0)
  58180. * @param m01 defines value for (0, 1)
  58181. * @param m10 defines value for (1, 0)
  58182. * @param m11 defines value for (1, 1)
  58183. * @param m20 defines value for (2, 0)
  58184. * @param m21 defines value for (2, 1)
  58185. * @returns the current modified matrix
  58186. */
  58187. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  58188. /**
  58189. * Gets matrix determinant
  58190. * @returns the determinant
  58191. */
  58192. determinant(): number;
  58193. /**
  58194. * Inverses the matrix and stores it in a target matrix
  58195. * @param result defines the target matrix
  58196. * @returns the current matrix
  58197. */
  58198. invertToRef(result: Matrix2D): Matrix2D;
  58199. /**
  58200. * Multiplies the current matrix with another one
  58201. * @param other defines the second operand
  58202. * @param result defines the target matrix
  58203. * @returns the current matrix
  58204. */
  58205. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  58206. /**
  58207. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  58208. * @param x defines the x coordinate to transform
  58209. * @param y defines the x coordinate to transform
  58210. * @param result defines the target vector2
  58211. * @returns the current matrix
  58212. */
  58213. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  58214. /**
  58215. * Creates an identity matrix
  58216. * @returns a new matrix
  58217. */
  58218. static Identity(): Matrix2D;
  58219. /**
  58220. * Creates a translation matrix and stores it in a target matrix
  58221. * @param x defines the x coordinate of the translation
  58222. * @param y defines the y coordinate of the translation
  58223. * @param result defines the target matrix
  58224. */
  58225. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  58226. /**
  58227. * Creates a scaling matrix and stores it in a target matrix
  58228. * @param x defines the x coordinate of the scaling
  58229. * @param y defines the y coordinate of the scaling
  58230. * @param result defines the target matrix
  58231. */
  58232. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  58233. /**
  58234. * Creates a rotation matrix and stores it in a target matrix
  58235. * @param angle defines the rotation angle
  58236. * @param result defines the target matrix
  58237. */
  58238. static RotationToRef(angle: number, result: Matrix2D): void;
  58239. private static _TempPreTranslationMatrix;
  58240. private static _TempPostTranslationMatrix;
  58241. private static _TempRotationMatrix;
  58242. private static _TempScalingMatrix;
  58243. private static _TempCompose0;
  58244. private static _TempCompose1;
  58245. private static _TempCompose2;
  58246. /**
  58247. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  58248. * @param tx defines the x coordinate of the translation
  58249. * @param ty defines the y coordinate of the translation
  58250. * @param angle defines the rotation angle
  58251. * @param scaleX defines the x coordinate of the scaling
  58252. * @param scaleY defines the y coordinate of the scaling
  58253. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  58254. * @param result defines the target matrix
  58255. */
  58256. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  58257. }
  58258. }
  58259. declare module BABYLON.GUI {
  58260. /**
  58261. * Class used to store 2D control sizes
  58262. */
  58263. export class Measure {
  58264. /** defines left coordinate */
  58265. left: number;
  58266. /** defines top coordinate */
  58267. top: number;
  58268. /** defines width dimension */
  58269. width: number;
  58270. /** defines height dimension */
  58271. height: number;
  58272. /**
  58273. * Creates a new measure
  58274. * @param left defines left coordinate
  58275. * @param top defines top coordinate
  58276. * @param width defines width dimension
  58277. * @param height defines height dimension
  58278. */
  58279. constructor(
  58280. /** defines left coordinate */
  58281. left: number,
  58282. /** defines top coordinate */
  58283. top: number,
  58284. /** defines width dimension */
  58285. width: number,
  58286. /** defines height dimension */
  58287. height: number);
  58288. /**
  58289. * Copy from another measure
  58290. * @param other defines the other measure to copy from
  58291. */
  58292. copyFrom(other: Measure): void;
  58293. /**
  58294. * Copy from a group of 4 floats
  58295. * @param left defines left coordinate
  58296. * @param top defines top coordinate
  58297. * @param width defines width dimension
  58298. * @param height defines height dimension
  58299. */
  58300. copyFromFloats(left: number, top: number, width: number, height: number): void;
  58301. /**
  58302. * Computes the axis aligned bounding box measure for two given measures
  58303. * @param a Input measure
  58304. * @param b Input measure
  58305. * @param result the resulting bounding measure
  58306. */
  58307. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  58308. /**
  58309. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  58310. * @param transform the matrix to transform the measure before computing the AABB
  58311. * @param result the resulting AABB
  58312. */
  58313. transformToRef(transform: Matrix2D, result: Measure): void;
  58314. /**
  58315. * Check equality between this measure and another one
  58316. * @param other defines the other measures
  58317. * @returns true if both measures are equals
  58318. */
  58319. isEqualsTo(other: Measure): boolean;
  58320. /**
  58321. * Creates an empty measure
  58322. * @returns a new measure
  58323. */
  58324. static Empty(): Measure;
  58325. }
  58326. }
  58327. declare module BABYLON.GUI {
  58328. /**
  58329. * Interface used to define a control that can receive focus
  58330. */
  58331. export interface IFocusableControl {
  58332. /**
  58333. * Function called when the control receives the focus
  58334. */
  58335. onFocus(): void;
  58336. /**
  58337. * Function called when the control loses the focus
  58338. */
  58339. onBlur(): void;
  58340. /**
  58341. * Function called to let the control handle keyboard events
  58342. * @param evt defines the current keyboard event
  58343. */
  58344. processKeyboard(evt: KeyboardEvent): void;
  58345. /**
  58346. * Function called to get the list of controls that should not steal the focus from this control
  58347. * @returns an array of controls
  58348. */
  58349. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58350. }
  58351. /**
  58352. * Class used to create texture to support 2D GUI elements
  58353. * @see http://doc.babylonjs.com/how_to/gui
  58354. */
  58355. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  58356. private _isDirty;
  58357. private _renderObserver;
  58358. private _resizeObserver;
  58359. private _preKeyboardObserver;
  58360. private _pointerMoveObserver;
  58361. private _pointerObserver;
  58362. private _canvasPointerOutObserver;
  58363. private _background;
  58364. /** @hidden */ private _rootContainer: Container;
  58365. /** @hidden */ private _lastPickedControl: Control;
  58366. /** @hidden */ private _lastControlOver: {
  58367. [pointerId: number]: Control;
  58368. };
  58369. /** @hidden */ private _lastControlDown: {
  58370. [pointerId: number]: Control;
  58371. };
  58372. /** @hidden */ private _capturingControl: {
  58373. [pointerId: number]: Control;
  58374. };
  58375. /** @hidden */ private _shouldBlockPointer: boolean;
  58376. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  58377. /** @hidden */ private _linkedControls: Control[];
  58378. private _isFullscreen;
  58379. private _fullscreenViewport;
  58380. private _idealWidth;
  58381. private _idealHeight;
  58382. private _useSmallestIdeal;
  58383. private _renderAtIdealSize;
  58384. private _focusedControl;
  58385. private _blockNextFocusCheck;
  58386. private _renderScale;
  58387. private _rootCanvas;
  58388. private _cursorChanged;
  58389. /**
  58390. * Define type to string to ensure compatibility across browsers
  58391. * Safari doesn't support DataTransfer constructor
  58392. */
  58393. private _clipboardData;
  58394. /**
  58395. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  58396. */
  58397. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  58398. /**
  58399. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  58400. */
  58401. onControlPickedObservable: BABYLON.Observable<Control>;
  58402. /**
  58403. * BABYLON.Observable event triggered before layout is evaluated
  58404. */
  58405. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58406. /**
  58407. * BABYLON.Observable event triggered after the layout was evaluated
  58408. */
  58409. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58410. /**
  58411. * BABYLON.Observable event triggered before the texture is rendered
  58412. */
  58413. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58414. /**
  58415. * BABYLON.Observable event triggered after the texture was rendered
  58416. */
  58417. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58418. /**
  58419. * Gets or sets a boolean defining if alpha is stored as premultiplied
  58420. */
  58421. premulAlpha: boolean;
  58422. /**
  58423. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  58424. * Useful when you want more antialiasing
  58425. */
  58426. renderScale: number;
  58427. /** Gets or sets the background color */
  58428. background: string;
  58429. /**
  58430. * Gets or sets the ideal width used to design controls.
  58431. * The GUI will then rescale everything accordingly
  58432. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58433. */
  58434. idealWidth: number;
  58435. /**
  58436. * Gets or sets the ideal height used to design controls.
  58437. * The GUI will then rescale everything accordingly
  58438. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58439. */
  58440. idealHeight: number;
  58441. /**
  58442. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  58443. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58444. */
  58445. useSmallestIdeal: boolean;
  58446. /**
  58447. * Gets or sets a boolean indicating if adaptive scaling must be used
  58448. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58449. */
  58450. renderAtIdealSize: boolean;
  58451. /**
  58452. * Gets the underlying layer used to render the texture when in fullscreen mode
  58453. */
  58454. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  58455. /**
  58456. * Gets the root container control
  58457. */
  58458. readonly rootContainer: Container;
  58459. /**
  58460. * Returns an array containing the root container.
  58461. * This is mostly used to let the Inspector introspects the ADT
  58462. * @returns an array containing the rootContainer
  58463. */
  58464. getChildren(): Array<Container>;
  58465. /**
  58466. * Will return all controls that are inside this texture
  58467. * @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
  58468. * @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
  58469. * @return all child controls
  58470. */
  58471. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  58472. /**
  58473. * Gets or sets the current focused control
  58474. */
  58475. focusedControl: BABYLON.Nullable<IFocusableControl>;
  58476. /**
  58477. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  58478. */
  58479. isForeground: boolean;
  58480. /**
  58481. * Gets or set information about clipboardData
  58482. */
  58483. clipboardData: string;
  58484. /**
  58485. * Creates a new AdvancedDynamicTexture
  58486. * @param name defines the name of the texture
  58487. * @param width defines the width of the texture
  58488. * @param height defines the height of the texture
  58489. * @param scene defines the hosting scene
  58490. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  58491. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  58492. */
  58493. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  58494. /**
  58495. * Get the current class name of the texture useful for serialization or dynamic coding.
  58496. * @returns "AdvancedDynamicTexture"
  58497. */
  58498. getClassName(): string;
  58499. /**
  58500. * Function used to execute a function on all controls
  58501. * @param func defines the function to execute
  58502. * @param container defines the container where controls belong. If null the root container will be used
  58503. */
  58504. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  58505. private _useInvalidateRectOptimization;
  58506. /**
  58507. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  58508. */
  58509. useInvalidateRectOptimization: boolean;
  58510. private _invalidatedRectangle;
  58511. /**
  58512. * Invalidates a rectangle area on the gui texture
  58513. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  58514. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  58515. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  58516. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  58517. */
  58518. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  58519. /**
  58520. * Marks the texture as dirty forcing a complete update
  58521. */
  58522. markAsDirty(): void;
  58523. /**
  58524. * Helper function used to create a new style
  58525. * @returns a new style
  58526. * @see http://doc.babylonjs.com/how_to/gui#styles
  58527. */
  58528. createStyle(): Style;
  58529. /**
  58530. * Adds a new control to the root container
  58531. * @param control defines the control to add
  58532. * @returns the current texture
  58533. */
  58534. addControl(control: Control): AdvancedDynamicTexture;
  58535. /**
  58536. * Removes a control from the root container
  58537. * @param control defines the control to remove
  58538. * @returns the current texture
  58539. */
  58540. removeControl(control: Control): AdvancedDynamicTexture;
  58541. /**
  58542. * Release all resources
  58543. */
  58544. dispose(): void;
  58545. private _onResize;
  58546. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  58547. /**
  58548. * Get screen coordinates for a vector3
  58549. * @param position defines the position to project
  58550. * @param worldMatrix defines the world matrix to use
  58551. * @returns the projected position
  58552. */
  58553. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  58554. private _checkUpdate;
  58555. private _clearMeasure;
  58556. private _render;
  58557. /** @hidden */ private _changeCursor(cursor: string): void;
  58558. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  58559. private _doPicking;
  58560. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  58561. [pointerId: number]: Control;
  58562. }, control: Control): void;
  58563. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  58564. /** Attach to all scene events required to support pointer events */
  58565. attach(): void;
  58566. /** @hidden */
  58567. private onClipboardCopy;
  58568. /** @hidden */
  58569. private onClipboardCut;
  58570. /** @hidden */
  58571. private onClipboardPaste;
  58572. /**
  58573. * Register the clipboard Events onto the canvas
  58574. */
  58575. registerClipboardEvents(): void;
  58576. /**
  58577. * Unregister the clipboard Events from the canvas
  58578. */
  58579. unRegisterClipboardEvents(): void;
  58580. /**
  58581. * Connect the texture to a hosting mesh to enable interactions
  58582. * @param mesh defines the mesh to attach to
  58583. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  58584. */
  58585. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  58586. /**
  58587. * Move the focus to a specific control
  58588. * @param control defines the control which will receive the focus
  58589. */
  58590. moveFocusToControl(control: IFocusableControl): void;
  58591. private _manageFocus;
  58592. private _attachToOnPointerOut;
  58593. /**
  58594. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  58595. * @param mesh defines the mesh which will receive the texture
  58596. * @param width defines the texture width (1024 by default)
  58597. * @param height defines the texture height (1024 by default)
  58598. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  58599. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  58600. * @returns a new AdvancedDynamicTexture
  58601. */
  58602. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  58603. /**
  58604. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  58605. * In this mode the texture will rely on a layer for its rendering.
  58606. * This allows it to be treated like any other layer.
  58607. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  58608. * LayerMask is set through advancedTexture.layer.layerMask
  58609. * @param name defines name for the texture
  58610. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  58611. * @param scene defines the hsoting scene
  58612. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  58613. * @returns a new AdvancedDynamicTexture
  58614. */
  58615. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  58616. }
  58617. }
  58618. declare module BABYLON.GUI {
  58619. /**
  58620. * Root class used for all 2D controls
  58621. * @see http://doc.babylonjs.com/how_to/gui#controls
  58622. */
  58623. export class Control {
  58624. /** defines the name of the control */
  58625. name?: string | undefined;
  58626. /**
  58627. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  58628. */
  58629. static AllowAlphaInheritance: boolean;
  58630. private _alpha;
  58631. private _alphaSet;
  58632. private _zIndex;
  58633. /** @hidden */ private _host: AdvancedDynamicTexture;
  58634. /** Gets or sets the control parent */
  58635. parent: BABYLON.Nullable<Container>;
  58636. /** @hidden */ private _currentMeasure: Measure;
  58637. private _fontFamily;
  58638. private _fontStyle;
  58639. private _fontWeight;
  58640. private _fontSize;
  58641. private _font;
  58642. /** @hidden */ private _width: ValueAndUnit;
  58643. /** @hidden */ private _height: ValueAndUnit;
  58644. /** @hidden */
  58645. protected _fontOffset: {
  58646. ascent: number;
  58647. height: number;
  58648. descent: number;
  58649. };
  58650. private _color;
  58651. private _style;
  58652. private _styleObserver;
  58653. /** @hidden */
  58654. protected _horizontalAlignment: number;
  58655. /** @hidden */
  58656. protected _verticalAlignment: number;
  58657. /** @hidden */
  58658. protected _isDirty: boolean;
  58659. /** @hidden */
  58660. protected _wasDirty: boolean;
  58661. /** @hidden */ private _tempParentMeasure: Measure;
  58662. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  58663. /** @hidden */
  58664. protected _cachedParentMeasure: Measure;
  58665. private _paddingLeft;
  58666. private _paddingRight;
  58667. private _paddingTop;
  58668. private _paddingBottom;
  58669. /** @hidden */ private _left: ValueAndUnit;
  58670. /** @hidden */ private _top: ValueAndUnit;
  58671. private _scaleX;
  58672. private _scaleY;
  58673. private _rotation;
  58674. private _transformCenterX;
  58675. private _transformCenterY;
  58676. /** @hidden */ private _transformMatrix: Matrix2D;
  58677. /** @hidden */
  58678. protected _invertTransformMatrix: Matrix2D;
  58679. /** @hidden */
  58680. protected _transformedPosition: BABYLON.Vector2;
  58681. private _isMatrixDirty;
  58682. private _cachedOffsetX;
  58683. private _cachedOffsetY;
  58684. private _isVisible;
  58685. private _isHighlighted;
  58686. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58687. private _fontSet;
  58688. private _dummyVector2;
  58689. private _downCount;
  58690. private _enterCount;
  58691. private _doNotRender;
  58692. private _downPointerIds;
  58693. protected _isEnabled: boolean;
  58694. protected _disabledColor: string;
  58695. /** @hidden */
  58696. protected _rebuildLayout: boolean;
  58697. /** @hidden */ private _isClipped: boolean;
  58698. /** @hidden */ private _tag: any;
  58699. /**
  58700. * 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
  58701. */
  58702. uniqueId: number;
  58703. /**
  58704. * Gets or sets an object used to store user defined information for the node
  58705. */
  58706. metadata: any;
  58707. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  58708. isHitTestVisible: boolean;
  58709. /** Gets or sets a boolean indicating if the control can block pointer events */
  58710. isPointerBlocker: boolean;
  58711. /** Gets or sets a boolean indicating if the control can be focusable */
  58712. isFocusInvisible: boolean;
  58713. /**
  58714. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  58715. * 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
  58716. */
  58717. clipChildren: boolean;
  58718. /**
  58719. * Gets or sets a boolean indicating that control content must be clipped
  58720. * 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
  58721. */
  58722. clipContent: boolean;
  58723. /**
  58724. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  58725. */
  58726. useBitmapCache: boolean;
  58727. private _cacheData;
  58728. private _shadowOffsetX;
  58729. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  58730. shadowOffsetX: number;
  58731. private _shadowOffsetY;
  58732. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  58733. shadowOffsetY: number;
  58734. private _shadowBlur;
  58735. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  58736. shadowBlur: number;
  58737. private _shadowColor;
  58738. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  58739. shadowColor: string;
  58740. /** Gets or sets the cursor to use when the control is hovered */
  58741. hoverCursor: string;
  58742. /** @hidden */
  58743. protected _linkOffsetX: ValueAndUnit;
  58744. /** @hidden */
  58745. protected _linkOffsetY: ValueAndUnit;
  58746. /** Gets the control type name */
  58747. readonly typeName: string;
  58748. /**
  58749. * Get the current class name of the control.
  58750. * @returns current class name
  58751. */
  58752. getClassName(): string;
  58753. /**
  58754. * An event triggered when the pointer move over the control.
  58755. */
  58756. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  58757. /**
  58758. * An event triggered when the pointer move out of the control.
  58759. */
  58760. onPointerOutObservable: BABYLON.Observable<Control>;
  58761. /**
  58762. * An event triggered when the pointer taps the control
  58763. */
  58764. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  58765. /**
  58766. * An event triggered when pointer up
  58767. */
  58768. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  58769. /**
  58770. * An event triggered when a control is clicked on
  58771. */
  58772. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  58773. /**
  58774. * An event triggered when pointer enters the control
  58775. */
  58776. onPointerEnterObservable: BABYLON.Observable<Control>;
  58777. /**
  58778. * An event triggered when the control is marked as dirty
  58779. */
  58780. onDirtyObservable: BABYLON.Observable<Control>;
  58781. /**
  58782. * An event triggered before drawing the control
  58783. */
  58784. onBeforeDrawObservable: BABYLON.Observable<Control>;
  58785. /**
  58786. * An event triggered after the control was drawn
  58787. */
  58788. onAfterDrawObservable: BABYLON.Observable<Control>;
  58789. /**
  58790. * Get the hosting AdvancedDynamicTexture
  58791. */
  58792. readonly host: AdvancedDynamicTexture;
  58793. /** Gets or set information about font offsets (used to render and align text) */
  58794. fontOffset: {
  58795. ascent: number;
  58796. height: number;
  58797. descent: number;
  58798. };
  58799. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  58800. alpha: number;
  58801. /**
  58802. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  58803. */
  58804. isHighlighted: boolean;
  58805. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  58806. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58807. */
  58808. scaleX: number;
  58809. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  58810. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58811. */
  58812. scaleY: number;
  58813. /** Gets or sets the rotation angle (0 by default)
  58814. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58815. */
  58816. rotation: number;
  58817. /** Gets or sets the transformation center on Y axis (0 by default)
  58818. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58819. */
  58820. transformCenterY: number;
  58821. /** Gets or sets the transformation center on X axis (0 by default)
  58822. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58823. */
  58824. transformCenterX: number;
  58825. /**
  58826. * Gets or sets the horizontal alignment
  58827. * @see http://doc.babylonjs.com/how_to/gui#alignments
  58828. */
  58829. horizontalAlignment: number;
  58830. /**
  58831. * Gets or sets the vertical alignment
  58832. * @see http://doc.babylonjs.com/how_to/gui#alignments
  58833. */
  58834. verticalAlignment: number;
  58835. /**
  58836. * Gets or sets control width
  58837. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58838. */
  58839. width: string | number;
  58840. /**
  58841. * Gets or sets the control width in pixel
  58842. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58843. */
  58844. widthInPixels: number;
  58845. /**
  58846. * Gets or sets control height
  58847. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58848. */
  58849. height: string | number;
  58850. /**
  58851. * Gets or sets control height in pixel
  58852. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58853. */
  58854. heightInPixels: number;
  58855. /** Gets or set font family */
  58856. fontFamily: string;
  58857. /** Gets or sets font style */
  58858. fontStyle: string;
  58859. /** Gets or sets font weight */
  58860. fontWeight: string;
  58861. /**
  58862. * Gets or sets style
  58863. * @see http://doc.babylonjs.com/how_to/gui#styles
  58864. */
  58865. style: BABYLON.Nullable<Style>;
  58866. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  58867. /** Gets or sets font size in pixels */
  58868. fontSizeInPixels: number;
  58869. /** Gets or sets font size */
  58870. fontSize: string | number;
  58871. /** Gets or sets foreground color */
  58872. color: string;
  58873. /** Gets or sets z index which is used to reorder controls on the z axis */
  58874. zIndex: number;
  58875. /** Gets or sets a boolean indicating if the control can be rendered */
  58876. notRenderable: boolean;
  58877. /** Gets or sets a boolean indicating if the control is visible */
  58878. isVisible: boolean;
  58879. /** Gets a boolean indicating that the control needs to update its rendering */
  58880. readonly isDirty: boolean;
  58881. /**
  58882. * Gets the current linked mesh (or null if none)
  58883. */
  58884. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58885. /**
  58886. * Gets or sets a value indicating the padding to use on the left of the control
  58887. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58888. */
  58889. paddingLeft: string | number;
  58890. /**
  58891. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  58892. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58893. */
  58894. paddingLeftInPixels: number;
  58895. /**
  58896. * Gets or sets a value indicating the padding to use on the right of the control
  58897. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58898. */
  58899. paddingRight: string | number;
  58900. /**
  58901. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  58902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58903. */
  58904. paddingRightInPixels: number;
  58905. /**
  58906. * Gets or sets a value indicating the padding to use on the top of the control
  58907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58908. */
  58909. paddingTop: string | number;
  58910. /**
  58911. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  58912. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58913. */
  58914. paddingTopInPixels: number;
  58915. /**
  58916. * Gets or sets a value indicating the padding to use on the bottom of the control
  58917. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58918. */
  58919. paddingBottom: string | number;
  58920. /**
  58921. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  58922. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58923. */
  58924. paddingBottomInPixels: number;
  58925. /**
  58926. * Gets or sets a value indicating the left coordinate of the control
  58927. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58928. */
  58929. left: string | number;
  58930. /**
  58931. * Gets or sets a value indicating the left coordinate in pixels of the control
  58932. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58933. */
  58934. leftInPixels: number;
  58935. /**
  58936. * Gets or sets a value indicating the top coordinate of the control
  58937. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58938. */
  58939. top: string | number;
  58940. /**
  58941. * Gets or sets a value indicating the top coordinate in pixels of the control
  58942. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58943. */
  58944. topInPixels: number;
  58945. /**
  58946. * Gets or sets a value indicating the offset on X axis to the linked mesh
  58947. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58948. */
  58949. linkOffsetX: string | number;
  58950. /**
  58951. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  58952. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58953. */
  58954. linkOffsetXInPixels: number;
  58955. /**
  58956. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  58957. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58958. */
  58959. linkOffsetY: string | number;
  58960. /**
  58961. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  58962. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58963. */
  58964. linkOffsetYInPixels: number;
  58965. /** Gets the center coordinate on X axis */
  58966. readonly centerX: number;
  58967. /** Gets the center coordinate on Y axis */
  58968. readonly centerY: number;
  58969. /** Gets or sets if control is Enabled*/
  58970. isEnabled: boolean;
  58971. /** Gets or sets background color of control if it's disabled*/
  58972. disabledColor: string;
  58973. /**
  58974. * Creates a new control
  58975. * @param name defines the name of the control
  58976. */
  58977. constructor(
  58978. /** defines the name of the control */
  58979. name?: string | undefined);
  58980. /** @hidden */
  58981. protected _getTypeName(): string;
  58982. /**
  58983. * Gets the first ascendant in the hierarchy of the given type
  58984. * @param className defines the required type
  58985. * @returns the ascendant or null if not found
  58986. */
  58987. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  58988. /** @hidden */ private _resetFontCache(): void;
  58989. /**
  58990. * Determines if a container is an ascendant of the current control
  58991. * @param container defines the container to look for
  58992. * @returns true if the container is one of the ascendant of the control
  58993. */
  58994. isAscendant(container: Control): boolean;
  58995. /**
  58996. * Gets coordinates in local control space
  58997. * @param globalCoordinates defines the coordinates to transform
  58998. * @returns the new coordinates in local space
  58999. */
  59000. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59001. /**
  59002. * Gets coordinates in local control space
  59003. * @param globalCoordinates defines the coordinates to transform
  59004. * @param result defines the target vector2 where to store the result
  59005. * @returns the current control
  59006. */
  59007. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  59008. /**
  59009. * Gets coordinates in parent local control space
  59010. * @param globalCoordinates defines the coordinates to transform
  59011. * @returns the new coordinates in parent local space
  59012. */
  59013. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59014. /**
  59015. * Move the current control to a vector3 position projected onto the screen.
  59016. * @param position defines the target position
  59017. * @param scene defines the hosting scene
  59018. */
  59019. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  59020. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59021. /**
  59022. * Will return all controls that have this control as ascendant
  59023. * @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
  59024. * @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
  59025. * @return all child controls
  59026. */
  59027. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59028. /**
  59029. * Link current control with a target mesh
  59030. * @param mesh defines the mesh to link with
  59031. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59032. */
  59033. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  59034. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  59035. /** @hidden */ private _offsetLeft(offset: number): void;
  59036. /** @hidden */ private _offsetTop(offset: number): void;
  59037. /** @hidden */ private _markMatrixAsDirty(): void;
  59038. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  59039. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  59040. /** @hidden */
  59041. protected invalidateRect(): void;
  59042. /** @hidden */ private _markAsDirty(force?: boolean): void;
  59043. /** @hidden */ private _markAllAsDirty(): void;
  59044. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  59045. /** @hidden */
  59046. protected _transform(context?: CanvasRenderingContext2D): void;
  59047. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  59048. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  59049. /** @hidden */
  59050. protected _applyStates(context: CanvasRenderingContext2D): void;
  59051. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  59052. /** @hidden */
  59053. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59054. protected _evaluateClippingState(parentMeasure: Measure): void;
  59055. /** @hidden */ private _measure(): void;
  59056. /** @hidden */
  59057. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59058. /** @hidden */
  59059. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59060. /** @hidden */
  59061. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59062. /** @hidden */
  59063. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  59064. private static _ClipMeasure;
  59065. private _tmpMeasureA;
  59066. private _clip;
  59067. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  59068. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  59069. /**
  59070. * Tests if a given coordinates belong to the current control
  59071. * @param x defines x coordinate to test
  59072. * @param y defines y coordinate to test
  59073. * @returns true if the coordinates are inside the control
  59074. */
  59075. contains(x: number, y: number): boolean;
  59076. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59077. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  59078. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  59079. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  59080. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59081. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59082. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59083. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  59084. private _prepareFont;
  59085. /** Releases associated resources */
  59086. dispose(): void;
  59087. private static _HORIZONTAL_ALIGNMENT_LEFT;
  59088. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  59089. private static _HORIZONTAL_ALIGNMENT_CENTER;
  59090. private static _VERTICAL_ALIGNMENT_TOP;
  59091. private static _VERTICAL_ALIGNMENT_BOTTOM;
  59092. private static _VERTICAL_ALIGNMENT_CENTER;
  59093. /** HORIZONTAL_ALIGNMENT_LEFT */
  59094. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  59095. /** HORIZONTAL_ALIGNMENT_RIGHT */
  59096. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  59097. /** HORIZONTAL_ALIGNMENT_CENTER */
  59098. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  59099. /** VERTICAL_ALIGNMENT_TOP */
  59100. static readonly VERTICAL_ALIGNMENT_TOP: number;
  59101. /** VERTICAL_ALIGNMENT_BOTTOM */
  59102. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  59103. /** VERTICAL_ALIGNMENT_CENTER */
  59104. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  59105. private static _FontHeightSizes;
  59106. /** @hidden */ private static _GetFontOffset(font: string): {
  59107. ascent: number;
  59108. height: number;
  59109. descent: number;
  59110. };
  59111. /**
  59112. * Creates a stack panel that can be used to render headers
  59113. * @param control defines the control to associate with the header
  59114. * @param text defines the text of the header
  59115. * @param size defines the size of the header
  59116. * @param options defines options used to configure the header
  59117. * @returns a new StackPanel
  59118. * @ignore
  59119. * @hidden
  59120. */
  59121. static AddHeader: (control: Control, text: string, size: string | number, options: {
  59122. isHorizontal: boolean;
  59123. controlFirst: boolean;
  59124. }) => any;
  59125. /** @hidden */
  59126. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  59127. }
  59128. }
  59129. declare module BABYLON.GUI {
  59130. /**
  59131. * Root class for 2D containers
  59132. * @see http://doc.babylonjs.com/how_to/gui#containers
  59133. */
  59134. export class Container extends Control {
  59135. name?: string | undefined;
  59136. /** @hidden */
  59137. protected _children: Control[];
  59138. /** @hidden */
  59139. protected _measureForChildren: Measure;
  59140. /** @hidden */
  59141. protected _background: string;
  59142. /** @hidden */
  59143. protected _adaptWidthToChildren: boolean;
  59144. /** @hidden */
  59145. protected _adaptHeightToChildren: boolean;
  59146. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  59147. adaptHeightToChildren: boolean;
  59148. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  59149. adaptWidthToChildren: boolean;
  59150. /** Gets or sets background color */
  59151. background: string;
  59152. /** Gets the list of children */
  59153. readonly children: Control[];
  59154. /**
  59155. * Creates a new Container
  59156. * @param name defines the name of the container
  59157. */
  59158. constructor(name?: string | undefined);
  59159. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  59160. /**
  59161. * Gets a child using its name
  59162. * @param name defines the child name to look for
  59163. * @returns the child control if found
  59164. */
  59165. getChildByName(name: string): BABYLON.Nullable<Control>;
  59166. /**
  59167. * Gets a child using its type and its name
  59168. * @param name defines the child name to look for
  59169. * @param type defines the child type to look for
  59170. * @returns the child control if found
  59171. */
  59172. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  59173. /**
  59174. * Search for a specific control in children
  59175. * @param control defines the control to look for
  59176. * @returns true if the control is in child list
  59177. */
  59178. containsControl(control: Control): boolean;
  59179. /**
  59180. * Adds a new control to the current container
  59181. * @param control defines the control to add
  59182. * @returns the current container
  59183. */
  59184. addControl(control: BABYLON.Nullable<Control>): Container;
  59185. /**
  59186. * Removes all controls from the current container
  59187. * @returns the current container
  59188. */
  59189. clearControls(): Container;
  59190. /**
  59191. * Removes a control from the current container
  59192. * @param control defines the control to remove
  59193. * @returns the current container
  59194. */
  59195. removeControl(control: Control): Container;
  59196. /** @hidden */ private _reOrderControl(control: Control): void;
  59197. /** @hidden */ private _offsetLeft(offset: number): void;
  59198. /** @hidden */ private _offsetTop(offset: number): void;
  59199. /** @hidden */ private _markAllAsDirty(): void;
  59200. /** @hidden */
  59201. protected _localDraw(context: CanvasRenderingContext2D): void;
  59202. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  59203. /** @hidden */
  59204. protected _beforeLayout(): void;
  59205. /** @hidden */
  59206. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59207. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  59208. protected _postMeasure(): void;
  59209. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  59210. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59211. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59212. /** @hidden */
  59213. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59214. /** Releases associated resources */
  59215. dispose(): void;
  59216. }
  59217. }
  59218. declare module BABYLON.GUI {
  59219. /** Class used to create rectangle container */
  59220. export class Rectangle extends Container {
  59221. name?: string | undefined;
  59222. private _thickness;
  59223. private _cornerRadius;
  59224. /** Gets or sets border thickness */
  59225. thickness: number;
  59226. /** Gets or sets the corner radius angle */
  59227. cornerRadius: number;
  59228. /**
  59229. * Creates a new Rectangle
  59230. * @param name defines the control name
  59231. */
  59232. constructor(name?: string | undefined);
  59233. protected _getTypeName(): string;
  59234. protected _localDraw(context: CanvasRenderingContext2D): void;
  59235. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59236. private _drawRoundedRect;
  59237. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  59238. }
  59239. }
  59240. declare module BABYLON.GUI {
  59241. /**
  59242. * Enum that determines the text-wrapping mode to use.
  59243. */
  59244. export enum TextWrapping {
  59245. /**
  59246. * Clip the text when it's larger than Control.width; this is the default mode.
  59247. */
  59248. Clip = 0,
  59249. /**
  59250. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  59251. */
  59252. WordWrap = 1,
  59253. /**
  59254. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  59255. */
  59256. Ellipsis = 2
  59257. }
  59258. /**
  59259. * Class used to create text block control
  59260. */
  59261. export class TextBlock extends Control {
  59262. /**
  59263. * Defines the name of the control
  59264. */
  59265. name?: string | undefined;
  59266. private _text;
  59267. private _textWrapping;
  59268. private _textHorizontalAlignment;
  59269. private _textVerticalAlignment;
  59270. private _lines;
  59271. private _resizeToFit;
  59272. private _lineSpacing;
  59273. private _outlineWidth;
  59274. private _outlineColor;
  59275. /**
  59276. * An event triggered after the text is changed
  59277. */
  59278. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  59279. /**
  59280. * An event triggered after the text was broken up into lines
  59281. */
  59282. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  59283. /**
  59284. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  59285. */
  59286. readonly lines: any[];
  59287. /**
  59288. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  59289. */
  59290. /**
  59291. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  59292. */
  59293. resizeToFit: boolean;
  59294. /**
  59295. * Gets or sets a boolean indicating if text must be wrapped
  59296. */
  59297. /**
  59298. * Gets or sets a boolean indicating if text must be wrapped
  59299. */
  59300. textWrapping: TextWrapping | boolean;
  59301. /**
  59302. * Gets or sets text to display
  59303. */
  59304. /**
  59305. * Gets or sets text to display
  59306. */
  59307. text: string;
  59308. /**
  59309. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  59310. */
  59311. /**
  59312. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  59313. */
  59314. textHorizontalAlignment: number;
  59315. /**
  59316. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  59317. */
  59318. /**
  59319. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  59320. */
  59321. textVerticalAlignment: number;
  59322. /**
  59323. * Gets or sets line spacing value
  59324. */
  59325. /**
  59326. * Gets or sets line spacing value
  59327. */
  59328. lineSpacing: string | number;
  59329. /**
  59330. * Gets or sets outlineWidth of the text to display
  59331. */
  59332. /**
  59333. * Gets or sets outlineWidth of the text to display
  59334. */
  59335. outlineWidth: number;
  59336. /**
  59337. * Gets or sets outlineColor of the text to display
  59338. */
  59339. /**
  59340. * Gets or sets outlineColor of the text to display
  59341. */
  59342. outlineColor: string;
  59343. /**
  59344. * Creates a new TextBlock object
  59345. * @param name defines the name of the control
  59346. * @param text defines the text to display (emptry string by default)
  59347. */
  59348. constructor(
  59349. /**
  59350. * Defines the name of the control
  59351. */
  59352. name?: string | undefined, text?: string);
  59353. protected _getTypeName(): string;
  59354. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59355. private _drawText;
  59356. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  59357. protected _applyStates(context: CanvasRenderingContext2D): void;
  59358. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  59359. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  59360. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  59361. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  59362. protected _renderLines(context: CanvasRenderingContext2D): void;
  59363. /**
  59364. * Given a width constraint applied on the text block, find the expected height
  59365. * @returns expected height
  59366. */
  59367. computeExpectedHeight(): number;
  59368. dispose(): void;
  59369. }
  59370. }
  59371. declare module BABYLON.GUI {
  59372. /**
  59373. * Class used to create 2D images
  59374. */
  59375. export class Image extends Control {
  59376. name?: string | undefined;
  59377. private static _WorkingCanvas;
  59378. private _domImage;
  59379. private _imageWidth;
  59380. private _imageHeight;
  59381. private _loaded;
  59382. private _stretch;
  59383. private _source;
  59384. private _autoScale;
  59385. private _sourceLeft;
  59386. private _sourceTop;
  59387. private _sourceWidth;
  59388. private _sourceHeight;
  59389. private _cellWidth;
  59390. private _cellHeight;
  59391. private _cellId;
  59392. private _populateNinePatchSlicesFromImage;
  59393. private _sliceLeft;
  59394. private _sliceRight;
  59395. private _sliceTop;
  59396. private _sliceBottom;
  59397. private _detectPointerOnOpaqueOnly;
  59398. /**
  59399. * BABYLON.Observable notified when the content is loaded
  59400. */
  59401. onImageLoadedObservable: BABYLON.Observable<Image>;
  59402. /**
  59403. * Gets a boolean indicating that the content is loaded
  59404. */
  59405. readonly isLoaded: boolean;
  59406. /**
  59407. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  59408. */
  59409. populateNinePatchSlicesFromImage: boolean;
  59410. /**
  59411. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  59412. * Beware using this as this will comsume more memory as the image has to be stored twice
  59413. */
  59414. detectPointerOnOpaqueOnly: boolean;
  59415. /**
  59416. * Gets or sets the left value for slicing (9-patch)
  59417. */
  59418. sliceLeft: number;
  59419. /**
  59420. * Gets or sets the right value for slicing (9-patch)
  59421. */
  59422. sliceRight: number;
  59423. /**
  59424. * Gets or sets the top value for slicing (9-patch)
  59425. */
  59426. sliceTop: number;
  59427. /**
  59428. * Gets or sets the bottom value for slicing (9-patch)
  59429. */
  59430. sliceBottom: number;
  59431. /**
  59432. * Gets or sets the left coordinate in the source image
  59433. */
  59434. sourceLeft: number;
  59435. /**
  59436. * Gets or sets the top coordinate in the source image
  59437. */
  59438. sourceTop: number;
  59439. /**
  59440. * Gets or sets the width to capture in the source image
  59441. */
  59442. sourceWidth: number;
  59443. /**
  59444. * Gets or sets the height to capture in the source image
  59445. */
  59446. sourceHeight: number;
  59447. /**
  59448. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  59449. * @see http://doc.babylonjs.com/how_to/gui#image
  59450. */
  59451. autoScale: boolean;
  59452. /** Gets or sets the streching mode used by the image */
  59453. stretch: number;
  59454. /**
  59455. * Gets or sets the internal DOM image used to render the control
  59456. */
  59457. domImage: HTMLImageElement;
  59458. private _onImageLoaded;
  59459. private _extractNinePatchSliceDataFromImage;
  59460. /**
  59461. * Gets or sets image source url
  59462. */
  59463. source: BABYLON.Nullable<string>;
  59464. /**
  59465. * Gets or sets the cell width to use when animation sheet is enabled
  59466. * @see http://doc.babylonjs.com/how_to/gui#image
  59467. */
  59468. cellWidth: number;
  59469. /**
  59470. * Gets or sets the cell height to use when animation sheet is enabled
  59471. * @see http://doc.babylonjs.com/how_to/gui#image
  59472. */
  59473. cellHeight: number;
  59474. /**
  59475. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  59476. * @see http://doc.babylonjs.com/how_to/gui#image
  59477. */
  59478. cellId: number;
  59479. /**
  59480. * Creates a new Image
  59481. * @param name defines the control name
  59482. * @param url defines the image url
  59483. */
  59484. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  59485. /**
  59486. * Tests if a given coordinates belong to the current control
  59487. * @param x defines x coordinate to test
  59488. * @param y defines y coordinate to test
  59489. * @returns true if the coordinates are inside the control
  59490. */
  59491. contains(x: number, y: number): boolean;
  59492. protected _getTypeName(): string;
  59493. /** Force the control to synchronize with its content */
  59494. synchronizeSizeWithContent(): void;
  59495. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59496. private _prepareWorkingCanvasForOpaqueDetection;
  59497. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  59498. private _renderCornerPatch;
  59499. private _renderNinePatch;
  59500. dispose(): void;
  59501. /** STRETCH_NONE */
  59502. static readonly STRETCH_NONE: number;
  59503. /** STRETCH_FILL */
  59504. static readonly STRETCH_FILL: number;
  59505. /** STRETCH_UNIFORM */
  59506. static readonly STRETCH_UNIFORM: number;
  59507. /** STRETCH_EXTEND */
  59508. static readonly STRETCH_EXTEND: number;
  59509. /** NINE_PATCH */
  59510. static readonly STRETCH_NINE_PATCH: number;
  59511. }
  59512. }
  59513. declare module BABYLON.GUI {
  59514. /**
  59515. * Class used to create 2D buttons
  59516. */
  59517. export class Button extends Rectangle {
  59518. name?: string | undefined;
  59519. /**
  59520. * Function called to generate a pointer enter animation
  59521. */
  59522. pointerEnterAnimation: () => void;
  59523. /**
  59524. * Function called to generate a pointer out animation
  59525. */
  59526. pointerOutAnimation: () => void;
  59527. /**
  59528. * Function called to generate a pointer down animation
  59529. */
  59530. pointerDownAnimation: () => void;
  59531. /**
  59532. * Function called to generate a pointer up animation
  59533. */
  59534. pointerUpAnimation: () => void;
  59535. private _image;
  59536. /**
  59537. * Returns the image part of the button (if any)
  59538. */
  59539. readonly image: BABYLON.Nullable<Image>;
  59540. private _textBlock;
  59541. /**
  59542. * Returns the image part of the button (if any)
  59543. */
  59544. readonly textBlock: BABYLON.Nullable<TextBlock>;
  59545. /**
  59546. * Creates a new Button
  59547. * @param name defines the name of the button
  59548. */
  59549. constructor(name?: string | undefined);
  59550. protected _getTypeName(): string;
  59551. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59552. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  59553. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  59554. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59555. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59556. /**
  59557. * Creates a new button made with an image and a text
  59558. * @param name defines the name of the button
  59559. * @param text defines the text of the button
  59560. * @param imageUrl defines the url of the image
  59561. * @returns a new Button
  59562. */
  59563. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  59564. /**
  59565. * Creates a new button made with an image
  59566. * @param name defines the name of the button
  59567. * @param imageUrl defines the url of the image
  59568. * @returns a new Button
  59569. */
  59570. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  59571. /**
  59572. * Creates a new button made with a text
  59573. * @param name defines the name of the button
  59574. * @param text defines the text of the button
  59575. * @returns a new Button
  59576. */
  59577. static CreateSimpleButton(name: string, text: string): Button;
  59578. /**
  59579. * Creates a new button made with an image and a centered text
  59580. * @param name defines the name of the button
  59581. * @param text defines the text of the button
  59582. * @param imageUrl defines the url of the image
  59583. * @returns a new Button
  59584. */
  59585. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  59586. }
  59587. }
  59588. declare module BABYLON.GUI {
  59589. /**
  59590. * Class used to create a 2D stack panel container
  59591. */
  59592. export class StackPanel extends Container {
  59593. name?: string | undefined;
  59594. private _isVertical;
  59595. private _manualWidth;
  59596. private _manualHeight;
  59597. private _doNotTrackManualChanges;
  59598. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  59599. isVertical: boolean;
  59600. /**
  59601. * Gets or sets panel width.
  59602. * This value should not be set when in horizontal mode as it will be computed automatically
  59603. */
  59604. width: string | number;
  59605. /**
  59606. * Gets or sets panel height.
  59607. * This value should not be set when in vertical mode as it will be computed automatically
  59608. */
  59609. height: string | number;
  59610. /**
  59611. * Creates a new StackPanel
  59612. * @param name defines control name
  59613. */
  59614. constructor(name?: string | undefined);
  59615. protected _getTypeName(): string;
  59616. /** @hidden */
  59617. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59618. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59619. protected _postMeasure(): void;
  59620. }
  59621. }
  59622. declare module BABYLON.GUI {
  59623. /**
  59624. * Class used to represent a 2D checkbox
  59625. */
  59626. export class Checkbox extends Control {
  59627. name?: string | undefined;
  59628. private _isChecked;
  59629. private _background;
  59630. private _checkSizeRatio;
  59631. private _thickness;
  59632. /** Gets or sets border thickness */
  59633. thickness: number;
  59634. /**
  59635. * BABYLON.Observable raised when isChecked property changes
  59636. */
  59637. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  59638. /** Gets or sets a value indicating the ratio between overall size and check size */
  59639. checkSizeRatio: number;
  59640. /** Gets or sets background color */
  59641. background: string;
  59642. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  59643. isChecked: boolean;
  59644. /**
  59645. * Creates a new CheckBox
  59646. * @param name defines the control name
  59647. */
  59648. constructor(name?: string | undefined);
  59649. protected _getTypeName(): string;
  59650. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  59651. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59652. /**
  59653. * Utility function to easily create a checkbox with a header
  59654. * @param title defines the label to use for the header
  59655. * @param onValueChanged defines the callback to call when value changes
  59656. * @returns a StackPanel containing the checkbox and a textBlock
  59657. */
  59658. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  59659. }
  59660. }
  59661. declare module BABYLON.GUI {
  59662. /**
  59663. * Class used to store key control properties
  59664. */
  59665. export class KeyPropertySet {
  59666. /** Width */
  59667. width?: string;
  59668. /** Height */
  59669. height?: string;
  59670. /** Left padding */
  59671. paddingLeft?: string;
  59672. /** Right padding */
  59673. paddingRight?: string;
  59674. /** Top padding */
  59675. paddingTop?: string;
  59676. /** Bottom padding */
  59677. paddingBottom?: string;
  59678. /** Foreground color */
  59679. color?: string;
  59680. /** Background color */
  59681. background?: string;
  59682. }
  59683. /**
  59684. * Class used to create virtual keyboard
  59685. */
  59686. export class VirtualKeyboard extends StackPanel {
  59687. /** BABYLON.Observable raised when a key is pressed */
  59688. onKeyPressObservable: BABYLON.Observable<string>;
  59689. /** Gets or sets default key button width */
  59690. defaultButtonWidth: string;
  59691. /** Gets or sets default key button height */
  59692. defaultButtonHeight: string;
  59693. /** Gets or sets default key button left padding */
  59694. defaultButtonPaddingLeft: string;
  59695. /** Gets or sets default key button right padding */
  59696. defaultButtonPaddingRight: string;
  59697. /** Gets or sets default key button top padding */
  59698. defaultButtonPaddingTop: string;
  59699. /** Gets or sets default key button bottom padding */
  59700. defaultButtonPaddingBottom: string;
  59701. /** Gets or sets default key button foreground color */
  59702. defaultButtonColor: string;
  59703. /** Gets or sets default key button background color */
  59704. defaultButtonBackground: string;
  59705. /** Gets or sets shift button foreground color */
  59706. shiftButtonColor: string;
  59707. /** Gets or sets shift button thickness*/
  59708. selectedShiftThickness: number;
  59709. /** Gets shift key state */
  59710. shiftState: number;
  59711. protected _getTypeName(): string;
  59712. private _createKey;
  59713. /**
  59714. * Adds a new row of keys
  59715. * @param keys defines the list of keys to add
  59716. * @param propertySets defines the associated property sets
  59717. */
  59718. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  59719. /**
  59720. * Set the shift key to a specific state
  59721. * @param shiftState defines the new shift state
  59722. */
  59723. applyShiftState(shiftState: number): void;
  59724. private _currentlyConnectedInputText;
  59725. private _connectedInputTexts;
  59726. private _onKeyPressObserver;
  59727. /** Gets the input text control currently attached to the keyboard */
  59728. readonly connectedInputText: BABYLON.Nullable<InputText>;
  59729. /**
  59730. * Connects the keyboard with an input text control
  59731. *
  59732. * @param input defines the target control
  59733. */
  59734. connect(input: InputText): void;
  59735. /**
  59736. * Disconnects the keyboard from connected InputText controls
  59737. *
  59738. * @param input optionally defines a target control, otherwise all are disconnected
  59739. */
  59740. disconnect(input?: InputText): void;
  59741. private _removeConnectedInputObservables;
  59742. /**
  59743. * Release all resources
  59744. */
  59745. dispose(): void;
  59746. /**
  59747. * Creates a new keyboard using a default layout
  59748. *
  59749. * @param name defines control name
  59750. * @returns a new VirtualKeyboard
  59751. */
  59752. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  59753. }
  59754. }
  59755. declare module BABYLON.GUI {
  59756. /**
  59757. * Class used to create input text control
  59758. */
  59759. export class InputText extends Control implements IFocusableControl {
  59760. name?: string | undefined;
  59761. private _text;
  59762. private _placeholderText;
  59763. private _background;
  59764. private _focusedBackground;
  59765. private _focusedColor;
  59766. private _placeholderColor;
  59767. private _thickness;
  59768. private _margin;
  59769. private _autoStretchWidth;
  59770. private _maxWidth;
  59771. private _isFocused;
  59772. private _blinkTimeout;
  59773. private _blinkIsEven;
  59774. private _cursorOffset;
  59775. private _scrollLeft;
  59776. private _textWidth;
  59777. private _clickedCoordinate;
  59778. private _deadKey;
  59779. private _addKey;
  59780. private _currentKey;
  59781. private _isTextHighlightOn;
  59782. private _textHighlightColor;
  59783. private _highligherOpacity;
  59784. private _highlightedText;
  59785. private _startHighlightIndex;
  59786. private _endHighlightIndex;
  59787. private _cursorIndex;
  59788. private _onFocusSelectAll;
  59789. private _isPointerDown;
  59790. private _onClipboardObserver;
  59791. private _onPointerDblTapObserver;
  59792. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  59793. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  59794. promptMessage: string;
  59795. /** BABYLON.Observable raised when the text changes */
  59796. onTextChangedObservable: BABYLON.Observable<InputText>;
  59797. /** BABYLON.Observable raised just before an entered character is to be added */
  59798. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  59799. /** BABYLON.Observable raised when the control gets the focus */
  59800. onFocusObservable: BABYLON.Observable<InputText>;
  59801. /** BABYLON.Observable raised when the control loses the focus */
  59802. onBlurObservable: BABYLON.Observable<InputText>;
  59803. /**Observable raised when the text is highlighted */
  59804. onTextHighlightObservable: BABYLON.Observable<InputText>;
  59805. /**Observable raised when copy event is triggered */
  59806. onTextCopyObservable: BABYLON.Observable<InputText>;
  59807. /** BABYLON.Observable raised when cut event is triggered */
  59808. onTextCutObservable: BABYLON.Observable<InputText>;
  59809. /** BABYLON.Observable raised when paste event is triggered */
  59810. onTextPasteObservable: BABYLON.Observable<InputText>;
  59811. /** BABYLON.Observable raised when a key event was processed */
  59812. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  59813. /** Gets or sets the maximum width allowed by the control */
  59814. maxWidth: string | number;
  59815. /** Gets the maximum width allowed by the control in pixels */
  59816. readonly maxWidthInPixels: number;
  59817. /** Gets or sets the text highlighter transparency; default: 0.4 */
  59818. highligherOpacity: number;
  59819. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  59820. onFocusSelectAll: boolean;
  59821. /** Gets or sets the text hightlight color */
  59822. textHighlightColor: string;
  59823. /** Gets or sets control margin */
  59824. margin: string;
  59825. /** Gets control margin in pixels */
  59826. readonly marginInPixels: number;
  59827. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  59828. autoStretchWidth: boolean;
  59829. /** Gets or sets border thickness */
  59830. thickness: number;
  59831. /** Gets or sets the background color when focused */
  59832. focusedBackground: string;
  59833. /** Gets or sets the background color when focused */
  59834. focusedColor: string;
  59835. /** Gets or sets the background color */
  59836. background: string;
  59837. /** Gets or sets the placeholder color */
  59838. placeholderColor: string;
  59839. /** Gets or sets the text displayed when the control is empty */
  59840. placeholderText: string;
  59841. /** Gets or sets the dead key flag */
  59842. deadKey: boolean;
  59843. /** Gets or sets the highlight text */
  59844. highlightedText: string;
  59845. /** Gets or sets if the current key should be added */
  59846. addKey: boolean;
  59847. /** Gets or sets the value of the current key being entered */
  59848. currentKey: string;
  59849. /** Gets or sets the text displayed in the control */
  59850. text: string;
  59851. /** Gets or sets control width */
  59852. width: string | number;
  59853. /**
  59854. * Creates a new InputText
  59855. * @param name defines the control name
  59856. * @param text defines the text of the control
  59857. */
  59858. constructor(name?: string | undefined, text?: string);
  59859. /** @hidden */
  59860. onBlur(): void;
  59861. /** @hidden */
  59862. onFocus(): void;
  59863. protected _getTypeName(): string;
  59864. /**
  59865. * Function called to get the list of controls that should not steal the focus from this control
  59866. * @returns an array of controls
  59867. */
  59868. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59869. /** @hidden */
  59870. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  59871. /** @hidden */
  59872. private _updateValueFromCursorIndex;
  59873. /** @hidden */
  59874. private _processDblClick;
  59875. /** @hidden */
  59876. private _selectAllText;
  59877. /**
  59878. * Handles the keyboard event
  59879. * @param evt Defines the KeyboardEvent
  59880. */
  59881. processKeyboard(evt: KeyboardEvent): void;
  59882. /** @hidden */
  59883. private _onCopyText;
  59884. /** @hidden */
  59885. private _onCutText;
  59886. /** @hidden */
  59887. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59888. protected _beforeRenderText(text: string): string;
  59889. dispose(): void;
  59890. }
  59891. }
  59892. declare module BABYLON.GUI {
  59893. /**
  59894. * Class used to create a 2D grid container
  59895. */
  59896. export class Grid extends Container {
  59897. name?: string | undefined;
  59898. private _rowDefinitions;
  59899. private _columnDefinitions;
  59900. private _cells;
  59901. private _childControls;
  59902. /**
  59903. * Gets the number of columns
  59904. */
  59905. readonly columnCount: number;
  59906. /**
  59907. * Gets the number of rows
  59908. */
  59909. readonly rowCount: number;
  59910. /** Gets the list of children */
  59911. readonly children: Control[];
  59912. /** Gets the list of cells (e.g. the containers) */
  59913. readonly cells: {
  59914. [key: string]: Container;
  59915. };
  59916. /**
  59917. * Gets the definition of a specific row
  59918. * @param index defines the index of the row
  59919. * @returns the row definition
  59920. */
  59921. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  59922. /**
  59923. * Gets the definition of a specific column
  59924. * @param index defines the index of the column
  59925. * @returns the column definition
  59926. */
  59927. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  59928. /**
  59929. * Adds a new row to the grid
  59930. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  59931. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  59932. * @returns the current grid
  59933. */
  59934. addRowDefinition(height: number, isPixel?: boolean): Grid;
  59935. /**
  59936. * Adds a new column to the grid
  59937. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  59938. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  59939. * @returns the current grid
  59940. */
  59941. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  59942. /**
  59943. * Update a row definition
  59944. * @param index defines the index of the row to update
  59945. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  59946. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  59947. * @returns the current grid
  59948. */
  59949. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  59950. /**
  59951. * Update a column definition
  59952. * @param index defines the index of the column to update
  59953. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  59954. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  59955. * @returns the current grid
  59956. */
  59957. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  59958. /**
  59959. * Gets the list of children stored in a specific cell
  59960. * @param row defines the row to check
  59961. * @param column defines the column to check
  59962. * @returns the list of controls
  59963. */
  59964. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  59965. /**
  59966. * Gets a string representing the child cell info (row x column)
  59967. * @param child defines the control to get info from
  59968. * @returns a string containing the child cell info (row x column)
  59969. */
  59970. getChildCellInfo(child: Control): string;
  59971. private _removeCell;
  59972. private _offsetCell;
  59973. /**
  59974. * Remove a column definition at specified index
  59975. * @param index defines the index of the column to remove
  59976. * @returns the current grid
  59977. */
  59978. removeColumnDefinition(index: number): Grid;
  59979. /**
  59980. * Remove a row definition at specified index
  59981. * @param index defines the index of the row to remove
  59982. * @returns the current grid
  59983. */
  59984. removeRowDefinition(index: number): Grid;
  59985. /**
  59986. * Adds a new control to the current grid
  59987. * @param control defines the control to add
  59988. * @param row defines the row where to add the control (0 by default)
  59989. * @param column defines the column where to add the control (0 by default)
  59990. * @returns the current grid
  59991. */
  59992. addControl(control: Control, row?: number, column?: number): Grid;
  59993. /**
  59994. * Removes a control from the current container
  59995. * @param control defines the control to remove
  59996. * @returns the current container
  59997. */
  59998. removeControl(control: Control): Container;
  59999. /**
  60000. * Creates a new Grid
  60001. * @param name defines control name
  60002. */
  60003. constructor(name?: string | undefined);
  60004. protected _getTypeName(): string;
  60005. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  60006. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60007. /** Releases associated resources */
  60008. dispose(): void;
  60009. }
  60010. }
  60011. declare module BABYLON.GUI {
  60012. /** Class used to create color pickers */
  60013. export class ColorPicker extends Control {
  60014. name?: string | undefined;
  60015. private static _Epsilon;
  60016. private _colorWheelCanvas;
  60017. private _value;
  60018. private _tmpColor;
  60019. private _pointerStartedOnSquare;
  60020. private _pointerStartedOnWheel;
  60021. private _squareLeft;
  60022. private _squareTop;
  60023. private _squareSize;
  60024. private _h;
  60025. private _s;
  60026. private _v;
  60027. private _lastPointerDownID;
  60028. /**
  60029. * BABYLON.Observable raised when the value changes
  60030. */
  60031. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  60032. /** Gets or sets the color of the color picker */
  60033. value: BABYLON.Color3;
  60034. /**
  60035. * Gets or sets control width
  60036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60037. */
  60038. width: string | number;
  60039. /**
  60040. * Gets or sets control height
  60041. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60042. */
  60043. /** Gets or sets control height */
  60044. height: string | number;
  60045. /** Gets or sets control size */
  60046. size: string | number;
  60047. /**
  60048. * Creates a new ColorPicker
  60049. * @param name defines the control name
  60050. */
  60051. constructor(name?: string | undefined);
  60052. protected _getTypeName(): string;
  60053. /** @hidden */
  60054. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60055. private _updateSquareProps;
  60056. private _drawGradientSquare;
  60057. private _drawCircle;
  60058. private _createColorWheelCanvas;
  60059. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60060. private _pointerIsDown;
  60061. private _updateValueFromPointer;
  60062. private _isPointOnSquare;
  60063. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60064. /**
  60065. * This function expands the color picker by creating a color picker dialog with manual
  60066. * color value input and the ability to save colors into an array to be used later in
  60067. * subsequent launches of the dialogue.
  60068. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  60069. * @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.
  60070. * @returns picked color as a hex string and the saved colors array as hex strings.
  60071. */
  60072. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  60073. pickerWidth?: string;
  60074. pickerHeight?: string;
  60075. headerHeight?: string;
  60076. lastColor?: string;
  60077. swatchLimit?: number;
  60078. numSwatchesPerLine?: number;
  60079. savedColors?: Array<string>;
  60080. }): Promise<{
  60081. savedColors?: string[];
  60082. pickedColor: string;
  60083. }>;
  60084. }
  60085. }
  60086. declare module BABYLON.GUI {
  60087. /** Class used to create 2D ellipse containers */
  60088. export class Ellipse extends Container {
  60089. name?: string | undefined;
  60090. private _thickness;
  60091. /** Gets or sets border thickness */
  60092. thickness: number;
  60093. /**
  60094. * Creates a new Ellipse
  60095. * @param name defines the control name
  60096. */
  60097. constructor(name?: string | undefined);
  60098. protected _getTypeName(): string;
  60099. protected _localDraw(context: CanvasRenderingContext2D): void;
  60100. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60101. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60102. }
  60103. }
  60104. declare module BABYLON.GUI {
  60105. /**
  60106. * Class used to create a password control
  60107. */
  60108. export class InputPassword extends InputText {
  60109. protected _beforeRenderText(text: string): string;
  60110. }
  60111. }
  60112. declare module BABYLON.GUI {
  60113. /** Class used to render 2D lines */
  60114. export class Line extends Control {
  60115. name?: string | undefined;
  60116. private _lineWidth;
  60117. private _x1;
  60118. private _y1;
  60119. private _x2;
  60120. private _y2;
  60121. private _dash;
  60122. private _connectedControl;
  60123. private _connectedControlDirtyObserver;
  60124. /** Gets or sets the dash pattern */
  60125. dash: Array<number>;
  60126. /** Gets or sets the control connected with the line end */
  60127. connectedControl: Control;
  60128. /** Gets or sets start coordinates on X axis */
  60129. x1: string | number;
  60130. /** Gets or sets start coordinates on Y axis */
  60131. y1: string | number;
  60132. /** Gets or sets end coordinates on X axis */
  60133. x2: string | number;
  60134. /** Gets or sets end coordinates on Y axis */
  60135. y2: string | number;
  60136. /** Gets or sets line width */
  60137. lineWidth: number;
  60138. /** Gets or sets horizontal alignment */
  60139. horizontalAlignment: number;
  60140. /** Gets or sets vertical alignment */
  60141. verticalAlignment: number;
  60142. private readonly _effectiveX2;
  60143. private readonly _effectiveY2;
  60144. /**
  60145. * Creates a new Line
  60146. * @param name defines the control name
  60147. */
  60148. constructor(name?: string | undefined);
  60149. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  60150. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60151. /**
  60152. * Move one end of the line given 3D cartesian coordinates.
  60153. * @param position Targeted world position
  60154. * @param scene BABYLON.Scene
  60155. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  60156. */
  60157. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  60158. /**
  60159. * Move one end of the line to a position in screen absolute space.
  60160. * @param projectedPosition Position in screen absolute space (X, Y)
  60161. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  60162. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  60163. }
  60164. }
  60165. declare module BABYLON.GUI {
  60166. /**
  60167. * Class used to store a point for a MultiLine object.
  60168. * The point can be pure 2D coordinates, a mesh or a control
  60169. */
  60170. export class MultiLinePoint {
  60171. private _multiLine;
  60172. private _x;
  60173. private _y;
  60174. private _control;
  60175. private _mesh;
  60176. private _controlObserver;
  60177. private _meshObserver;
  60178. /** @hidden */ private _point: BABYLON.Vector2;
  60179. /**
  60180. * Creates a new MultiLinePoint
  60181. * @param multiLine defines the source MultiLine object
  60182. */
  60183. constructor(multiLine: MultiLine);
  60184. /** Gets or sets x coordinate */
  60185. x: string | number;
  60186. /** Gets or sets y coordinate */
  60187. y: string | number;
  60188. /** Gets or sets the control associated with this point */
  60189. control: BABYLON.Nullable<Control>;
  60190. /** Gets or sets the mesh associated with this point */
  60191. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60192. /** Resets links */
  60193. resetLinks(): void;
  60194. /**
  60195. * Gets a translation vector
  60196. * @returns the translation vector
  60197. */
  60198. translate(): BABYLON.Vector2;
  60199. private _translatePoint;
  60200. /** Release associated resources */
  60201. dispose(): void;
  60202. }
  60203. }
  60204. declare module BABYLON.GUI {
  60205. /**
  60206. * Class used to create multi line control
  60207. */
  60208. export class MultiLine extends Control {
  60209. name?: string | undefined;
  60210. private _lineWidth;
  60211. private _dash;
  60212. private _points;
  60213. private _minX;
  60214. private _minY;
  60215. private _maxX;
  60216. private _maxY;
  60217. /**
  60218. * Creates a new MultiLine
  60219. * @param name defines the control name
  60220. */
  60221. constructor(name?: string | undefined);
  60222. /** Gets or sets dash pattern */
  60223. dash: Array<number>;
  60224. /**
  60225. * Gets point stored at specified index
  60226. * @param index defines the index to look for
  60227. * @returns the requested point if found
  60228. */
  60229. getAt(index: number): MultiLinePoint;
  60230. /** Function called when a point is updated */
  60231. onPointUpdate: () => void;
  60232. /**
  60233. * Adds new points to the point collection
  60234. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  60235. * @returns the list of created MultiLinePoint
  60236. */
  60237. add(...items: (AbstractMesh | Control | {
  60238. x: string | number;
  60239. y: string | number;
  60240. })[]): MultiLinePoint[];
  60241. /**
  60242. * Adds a new point to the point collection
  60243. * @param item defines the item (mesh, control or 2d coordiantes) to add
  60244. * @returns the created MultiLinePoint
  60245. */
  60246. push(item?: (AbstractMesh | Control | {
  60247. x: string | number;
  60248. y: string | number;
  60249. })): MultiLinePoint;
  60250. /**
  60251. * Remove a specific value or point from the active point collection
  60252. * @param value defines the value or point to remove
  60253. */
  60254. remove(value: number | MultiLinePoint): void;
  60255. /**
  60256. * Resets this object to initial state (no point)
  60257. */
  60258. reset(): void;
  60259. /**
  60260. * Resets all links
  60261. */
  60262. resetLinks(): void;
  60263. /** Gets or sets line width */
  60264. lineWidth: number;
  60265. horizontalAlignment: number;
  60266. verticalAlignment: number;
  60267. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  60268. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  60269. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60270. dispose(): void;
  60271. }
  60272. }
  60273. declare module BABYLON.GUI {
  60274. /**
  60275. * Class used to create radio button controls
  60276. */
  60277. export class RadioButton extends Control {
  60278. name?: string | undefined;
  60279. private _isChecked;
  60280. private _background;
  60281. private _checkSizeRatio;
  60282. private _thickness;
  60283. /** Gets or sets border thickness */
  60284. thickness: number;
  60285. /** Gets or sets group name */
  60286. group: string;
  60287. /** BABYLON.Observable raised when isChecked is changed */
  60288. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60289. /** Gets or sets a value indicating the ratio between overall size and check size */
  60290. checkSizeRatio: number;
  60291. /** Gets or sets background color */
  60292. background: string;
  60293. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60294. isChecked: boolean;
  60295. /**
  60296. * Creates a new RadioButton
  60297. * @param name defines the control name
  60298. */
  60299. constructor(name?: string | undefined);
  60300. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60301. /**
  60302. * Utility function to easily create a radio button with a header
  60303. * @param title defines the label to use for the header
  60304. * @param group defines the group to use for the radio button
  60305. * @param isChecked defines the initial state of the radio button
  60306. * @param onValueChanged defines the callback to call when value changes
  60307. * @returns a StackPanel containing the radio button and a textBlock
  60308. */
  60309. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  60310. }
  60311. }
  60312. declare module BABYLON.GUI {
  60313. /**
  60314. * Class used to create slider controls
  60315. */
  60316. export class BaseSlider extends Control {
  60317. name?: string | undefined;
  60318. protected _thumbWidth: ValueAndUnit;
  60319. private _minimum;
  60320. private _maximum;
  60321. private _value;
  60322. private _isVertical;
  60323. protected _barOffset: ValueAndUnit;
  60324. private _isThumbClamped;
  60325. protected _displayThumb: boolean;
  60326. private _step;
  60327. private _lastPointerDownID;
  60328. protected _effectiveBarOffset: number;
  60329. protected _renderLeft: number;
  60330. protected _renderTop: number;
  60331. protected _renderWidth: number;
  60332. protected _renderHeight: number;
  60333. protected _backgroundBoxLength: number;
  60334. protected _backgroundBoxThickness: number;
  60335. protected _effectiveThumbThickness: number;
  60336. /** BABYLON.Observable raised when the sldier value changes */
  60337. onValueChangedObservable: BABYLON.Observable<number>;
  60338. /** Gets or sets a boolean indicating if the thumb must be rendered */
  60339. displayThumb: boolean;
  60340. /** Gets or sets a step to apply to values (0 by default) */
  60341. step: number;
  60342. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  60343. barOffset: string | number;
  60344. /** Gets main bar offset in pixels*/
  60345. readonly barOffsetInPixels: number;
  60346. /** Gets or sets thumb width */
  60347. thumbWidth: string | number;
  60348. /** Gets thumb width in pixels */
  60349. readonly thumbWidthInPixels: number;
  60350. /** Gets or sets minimum value */
  60351. minimum: number;
  60352. /** Gets or sets maximum value */
  60353. maximum: number;
  60354. /** Gets or sets current value */
  60355. value: number;
  60356. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  60357. isVertical: boolean;
  60358. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  60359. isThumbClamped: boolean;
  60360. /**
  60361. * Creates a new BaseSlider
  60362. * @param name defines the control name
  60363. */
  60364. constructor(name?: string | undefined);
  60365. protected _getTypeName(): string;
  60366. protected _getThumbPosition(): number;
  60367. protected _getThumbThickness(type: string): number;
  60368. protected _prepareRenderingData(type: string): void;
  60369. private _pointerIsDown;
  60370. /** @hidden */
  60371. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60372. }
  60373. }
  60374. declare module BABYLON.GUI {
  60375. /**
  60376. * Class used to create slider controls
  60377. */
  60378. export class Slider extends BaseSlider {
  60379. name?: string | undefined;
  60380. private _background;
  60381. private _borderColor;
  60382. private _isThumbCircle;
  60383. protected _displayValueBar: boolean;
  60384. /** Gets or sets a boolean indicating if the value bar must be rendered */
  60385. displayValueBar: boolean;
  60386. /** Gets or sets border color */
  60387. borderColor: string;
  60388. /** Gets or sets background color */
  60389. background: string;
  60390. /** Gets or sets a boolean indicating if the thumb should be round or square */
  60391. isThumbCircle: boolean;
  60392. /**
  60393. * Creates a new Slider
  60394. * @param name defines the control name
  60395. */
  60396. constructor(name?: string | undefined);
  60397. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  60398. }
  60399. }
  60400. declare module BABYLON.GUI {
  60401. /** Class used to create a RadioGroup
  60402. * which contains groups of radio buttons
  60403. */
  60404. export class SelectorGroup {
  60405. /** name of SelectorGroup */
  60406. name: string;
  60407. private _groupPanel;
  60408. private _selectors;
  60409. private _groupHeader;
  60410. /**
  60411. * Creates a new SelectorGroup
  60412. * @param name of group, used as a group heading
  60413. */
  60414. constructor(
  60415. /** name of SelectorGroup */
  60416. name: string);
  60417. /** Gets the groupPanel of the SelectorGroup */
  60418. readonly groupPanel: StackPanel;
  60419. /** Gets the selectors array */
  60420. readonly selectors: StackPanel[];
  60421. /** Gets and sets the group header */
  60422. header: string;
  60423. /** @hidden */
  60424. private _addGroupHeader;
  60425. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  60426. /** Removes the selector at the given position
  60427. * @param selectorNb the position of the selector within the group
  60428. */
  60429. removeSelector(selectorNb: number): void;
  60430. }
  60431. /** Class used to create a CheckboxGroup
  60432. * which contains groups of checkbox buttons
  60433. */
  60434. export class CheckboxGroup extends SelectorGroup {
  60435. /** Adds a checkbox as a control
  60436. * @param text is the label for the selector
  60437. * @param func is the function called when the Selector is checked
  60438. * @param checked is true when Selector is checked
  60439. */
  60440. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  60441. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  60442. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  60443. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  60444. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  60445. }
  60446. /** Class used to create a RadioGroup
  60447. * which contains groups of radio buttons
  60448. */
  60449. export class RadioGroup extends SelectorGroup {
  60450. private _selectNb;
  60451. /** Adds a radio button as a control
  60452. * @param label is the label for the selector
  60453. * @param func is the function called when the Selector is checked
  60454. * @param checked is true when Selector is checked
  60455. */
  60456. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  60457. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  60458. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  60459. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  60460. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  60461. }
  60462. /** Class used to create a SliderGroup
  60463. * which contains groups of slider buttons
  60464. */
  60465. export class SliderGroup extends SelectorGroup {
  60466. /**
  60467. * Adds a slider to the SelectorGroup
  60468. * @param label is the label for the SliderBar
  60469. * @param func is the function called when the Slider moves
  60470. * @param unit is a string describing the units used, eg degrees or metres
  60471. * @param min is the minimum value for the Slider
  60472. * @param max is the maximum value for the Slider
  60473. * @param value is the start value for the Slider between min and max
  60474. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  60475. */
  60476. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  60477. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  60478. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  60479. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  60480. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  60481. }
  60482. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  60483. * @see http://doc.babylonjs.com/how_to/selector
  60484. */
  60485. export class SelectionPanel extends Rectangle {
  60486. /** name of SelectionPanel */
  60487. name: string;
  60488. /** an array of SelectionGroups */
  60489. groups: SelectorGroup[];
  60490. private _panel;
  60491. private _buttonColor;
  60492. private _buttonBackground;
  60493. private _headerColor;
  60494. private _barColor;
  60495. private _barHeight;
  60496. private _spacerHeight;
  60497. private _labelColor;
  60498. private _groups;
  60499. private _bars;
  60500. /**
  60501. * Creates a new SelectionPanel
  60502. * @param name of SelectionPanel
  60503. * @param groups is an array of SelectionGroups
  60504. */
  60505. constructor(
  60506. /** name of SelectionPanel */
  60507. name: string,
  60508. /** an array of SelectionGroups */
  60509. groups?: SelectorGroup[]);
  60510. protected _getTypeName(): string;
  60511. /** Gets or sets the headerColor */
  60512. headerColor: string;
  60513. private _setHeaderColor;
  60514. /** Gets or sets the button color */
  60515. buttonColor: string;
  60516. private _setbuttonColor;
  60517. /** Gets or sets the label color */
  60518. labelColor: string;
  60519. private _setLabelColor;
  60520. /** Gets or sets the button background */
  60521. buttonBackground: string;
  60522. private _setButtonBackground;
  60523. /** Gets or sets the color of separator bar */
  60524. barColor: string;
  60525. private _setBarColor;
  60526. /** Gets or sets the height of separator bar */
  60527. barHeight: string;
  60528. private _setBarHeight;
  60529. /** Gets or sets the height of spacers*/
  60530. spacerHeight: string;
  60531. private _setSpacerHeight;
  60532. /** Adds a bar between groups */
  60533. private _addSpacer;
  60534. /** Add a group to the selection panel
  60535. * @param group is the selector group to add
  60536. */
  60537. addGroup(group: SelectorGroup): void;
  60538. /** Remove the group from the given position
  60539. * @param groupNb is the position of the group in the list
  60540. */
  60541. removeGroup(groupNb: number): void;
  60542. /** Change a group header label
  60543. * @param label is the new group header label
  60544. * @param groupNb is the number of the group to relabel
  60545. * */
  60546. setHeaderName(label: string, groupNb: number): void;
  60547. /** Change selector label to the one given
  60548. * @param label is the new selector label
  60549. * @param groupNb is the number of the groupcontaining the selector
  60550. * @param selectorNb is the number of the selector within a group to relabel
  60551. * */
  60552. relabel(label: string, groupNb: number, selectorNb: number): void;
  60553. /** For a given group position remove the selector at the given position
  60554. * @param groupNb is the number of the group to remove the selector from
  60555. * @param selectorNb is the number of the selector within the group
  60556. */
  60557. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  60558. /** For a given group position of correct type add a checkbox button
  60559. * @param groupNb is the number of the group to remove the selector from
  60560. * @param label is the label for the selector
  60561. * @param func is the function called when the Selector is checked
  60562. * @param checked is true when Selector is checked
  60563. */
  60564. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  60565. /** For a given group position of correct type add a radio button
  60566. * @param groupNb is the number of the group to remove the selector from
  60567. * @param label is the label for the selector
  60568. * @param func is the function called when the Selector is checked
  60569. * @param checked is true when Selector is checked
  60570. */
  60571. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  60572. /**
  60573. * For a given slider group add a slider
  60574. * @param groupNb is the number of the group to add the slider to
  60575. * @param label is the label for the Slider
  60576. * @param func is the function called when the Slider moves
  60577. * @param unit is a string describing the units used, eg degrees or metres
  60578. * @param min is the minimum value for the Slider
  60579. * @param max is the maximum value for the Slider
  60580. * @param value is the start value for the Slider between min and max
  60581. * @param onVal is the function used to format the value displayed, eg radians to degrees
  60582. */
  60583. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  60584. }
  60585. }
  60586. declare module BABYLON.GUI {
  60587. /**
  60588. * Class used to hold a the container for ScrollViewer
  60589. * @hidden
  60590. */
  60591. export class _ScrollViewerWindow extends Container {
  60592. parentClientWidth: number;
  60593. parentClientHeight: number;
  60594. /**
  60595. * Creates a new ScrollViewerWindow
  60596. * @param name of ScrollViewerWindow
  60597. */
  60598. constructor(name?: string);
  60599. protected _getTypeName(): string;
  60600. /** @hidden */
  60601. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60602. protected _postMeasure(): void;
  60603. }
  60604. }
  60605. declare module BABYLON.GUI {
  60606. /**
  60607. * Class used to create slider controls
  60608. */
  60609. export class ScrollBar extends BaseSlider {
  60610. name?: string | undefined;
  60611. private _background;
  60612. private _borderColor;
  60613. private _thumbMeasure;
  60614. /** Gets or sets border color */
  60615. borderColor: string;
  60616. /** Gets or sets background color */
  60617. background: string;
  60618. /**
  60619. * Creates a new Slider
  60620. * @param name defines the control name
  60621. */
  60622. constructor(name?: string | undefined);
  60623. protected _getTypeName(): string;
  60624. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  60625. private _first;
  60626. private _originX;
  60627. private _originY;
  60628. /** @hidden */
  60629. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60630. }
  60631. }
  60632. declare module BABYLON.GUI {
  60633. /**
  60634. * Class used to hold a viewer window and sliders in a grid
  60635. */
  60636. export class ScrollViewer extends Rectangle {
  60637. private _grid;
  60638. private _horizontalBarSpace;
  60639. private _verticalBarSpace;
  60640. private _dragSpace;
  60641. private _horizontalBar;
  60642. private _verticalBar;
  60643. private _barColor;
  60644. private _barBackground;
  60645. private _barSize;
  60646. private _endLeft;
  60647. private _endTop;
  60648. private _window;
  60649. private _pointerIsOver;
  60650. private _wheelPrecision;
  60651. private _onPointerObserver;
  60652. private _clientWidth;
  60653. private _clientHeight;
  60654. /**
  60655. * Gets the horizontal scrollbar
  60656. */
  60657. readonly horizontalBar: ScrollBar;
  60658. /**
  60659. * Gets the vertical scrollbar
  60660. */
  60661. readonly verticalBar: ScrollBar;
  60662. /**
  60663. * Adds a new control to the current container
  60664. * @param control defines the control to add
  60665. * @returns the current container
  60666. */
  60667. addControl(control: BABYLON.Nullable<Control>): Container;
  60668. /**
  60669. * Removes a control from the current container
  60670. * @param control defines the control to remove
  60671. * @returns the current container
  60672. */
  60673. removeControl(control: Control): Container;
  60674. /** Gets the list of children */
  60675. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  60676. /**
  60677. * Creates a new ScrollViewer
  60678. * @param name of ScrollViewer
  60679. */
  60680. constructor(name?: string);
  60681. /** Reset the scroll viewer window to initial size */
  60682. resetWindow(): void;
  60683. protected _getTypeName(): string;
  60684. private _buildClientSizes;
  60685. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60686. protected _postMeasure(): void;
  60687. /**
  60688. * Gets or sets the mouse wheel precision
  60689. * from 0 to 1 with a default value of 0.05
  60690. * */
  60691. wheelPrecision: number;
  60692. /** Gets or sets the bar color */
  60693. barColor: string;
  60694. /** Gets or sets the size of the bar */
  60695. barSize: number;
  60696. /** Gets or sets the bar background */
  60697. barBackground: string;
  60698. /** @hidden */
  60699. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  60700. /** @hidden */
  60701. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60702. /** Releases associated resources */
  60703. dispose(): void;
  60704. }
  60705. }
  60706. declare module BABYLON.GUI {
  60707. /** Class used to render a grid */
  60708. export class DisplayGrid extends Control {
  60709. name?: string | undefined;
  60710. private _cellWidth;
  60711. private _cellHeight;
  60712. private _minorLineTickness;
  60713. private _minorLineColor;
  60714. private _majorLineTickness;
  60715. private _majorLineColor;
  60716. private _majorLineFrequency;
  60717. private _background;
  60718. private _displayMajorLines;
  60719. private _displayMinorLines;
  60720. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  60721. displayMinorLines: boolean;
  60722. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  60723. displayMajorLines: boolean;
  60724. /** Gets or sets background color (Black by default) */
  60725. background: string;
  60726. /** Gets or sets the width of each cell (20 by default) */
  60727. cellWidth: number;
  60728. /** Gets or sets the height of each cell (20 by default) */
  60729. cellHeight: number;
  60730. /** Gets or sets the tickness of minor lines (1 by default) */
  60731. minorLineTickness: number;
  60732. /** Gets or sets the color of minor lines (DarkGray by default) */
  60733. minorLineColor: string;
  60734. /** Gets or sets the tickness of major lines (2 by default) */
  60735. majorLineTickness: number;
  60736. /** Gets or sets the color of major lines (White by default) */
  60737. majorLineColor: string;
  60738. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  60739. majorLineFrequency: number;
  60740. /**
  60741. * Creates a new GridDisplayRectangle
  60742. * @param name defines the control name
  60743. */
  60744. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  60745. protected _getTypeName(): string;
  60746. }
  60747. }
  60748. declare module BABYLON.GUI {
  60749. /**
  60750. * Class used to create slider controls based on images
  60751. */
  60752. export class ImageBasedSlider extends BaseSlider {
  60753. name?: string | undefined;
  60754. private _backgroundImage;
  60755. private _thumbImage;
  60756. private _valueBarImage;
  60757. private _tempMeasure;
  60758. displayThumb: boolean;
  60759. /**
  60760. * Gets or sets the image used to render the background
  60761. */
  60762. backgroundImage: Image;
  60763. /**
  60764. * Gets or sets the image used to render the value bar
  60765. */
  60766. valueBarImage: Image;
  60767. /**
  60768. * Gets or sets the image used to render the thumb
  60769. */
  60770. thumbImage: Image;
  60771. /**
  60772. * Creates a new ImageBasedSlider
  60773. * @param name defines the control name
  60774. */
  60775. constructor(name?: string | undefined);
  60776. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  60777. }
  60778. }
  60779. declare module BABYLON.GUI {
  60780. /**
  60781. * Forcing an export so that this code will execute
  60782. * @hidden
  60783. */
  60784. const name = "Statics";
  60785. }
  60786. declare module BABYLON.GUI {
  60787. /**
  60788. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  60789. */
  60790. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  60791. /**
  60792. * Define the instrumented AdvancedDynamicTexture.
  60793. */
  60794. texture: AdvancedDynamicTexture;
  60795. private _captureRenderTime;
  60796. private _renderTime;
  60797. private _captureLayoutTime;
  60798. private _layoutTime;
  60799. private _onBeginRenderObserver;
  60800. private _onEndRenderObserver;
  60801. private _onBeginLayoutObserver;
  60802. private _onEndLayoutObserver;
  60803. /**
  60804. * Gets the perf counter used to capture render time
  60805. */
  60806. readonly renderTimeCounter: BABYLON.PerfCounter;
  60807. /**
  60808. * Gets the perf counter used to capture layout time
  60809. */
  60810. readonly layoutTimeCounter: BABYLON.PerfCounter;
  60811. /**
  60812. * Enable or disable the render time capture
  60813. */
  60814. captureRenderTime: boolean;
  60815. /**
  60816. * Enable or disable the layout time capture
  60817. */
  60818. captureLayoutTime: boolean;
  60819. /**
  60820. * Instantiates a new advanced dynamic texture instrumentation.
  60821. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  60822. * @param texture Defines the AdvancedDynamicTexture to instrument
  60823. */
  60824. constructor(
  60825. /**
  60826. * Define the instrumented AdvancedDynamicTexture.
  60827. */
  60828. texture: AdvancedDynamicTexture);
  60829. /**
  60830. * Dispose and release associated resources.
  60831. */
  60832. dispose(): void;
  60833. }
  60834. }
  60835. declare module BABYLON.GUI {
  60836. /**
  60837. * Class used to create containers for controls
  60838. */
  60839. export class Container3D extends Control3D {
  60840. private _blockLayout;
  60841. /**
  60842. * Gets the list of child controls
  60843. */
  60844. protected _children: Control3D[];
  60845. /**
  60846. * Gets the list of child controls
  60847. */
  60848. readonly children: Array<Control3D>;
  60849. /**
  60850. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  60851. * This is helpful to optimize layout operation when adding multiple children in a row
  60852. */
  60853. blockLayout: boolean;
  60854. /**
  60855. * Creates a new container
  60856. * @param name defines the container name
  60857. */
  60858. constructor(name?: string);
  60859. /**
  60860. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  60861. * @returns the current container
  60862. */
  60863. updateLayout(): Container3D;
  60864. /**
  60865. * Gets a boolean indicating if the given control is in the children of this control
  60866. * @param control defines the control to check
  60867. * @returns true if the control is in the child list
  60868. */
  60869. containsControl(control: Control3D): boolean;
  60870. /**
  60871. * Adds a control to the children of this control
  60872. * @param control defines the control to add
  60873. * @returns the current container
  60874. */
  60875. addControl(control: Control3D): Container3D;
  60876. /**
  60877. * This function will be called everytime a new control is added
  60878. */
  60879. protected _arrangeChildren(): void;
  60880. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  60881. /**
  60882. * Removes a control from the children of this control
  60883. * @param control defines the control to remove
  60884. * @returns the current container
  60885. */
  60886. removeControl(control: Control3D): Container3D;
  60887. protected _getTypeName(): string;
  60888. /**
  60889. * Releases all associated resources
  60890. */
  60891. dispose(): void;
  60892. /** Control rotation will remain unchanged */
  60893. static readonly UNSET_ORIENTATION: number;
  60894. /** Control will rotate to make it look at sphere central axis */
  60895. static readonly FACEORIGIN_ORIENTATION: number;
  60896. /** Control will rotate to make it look back at sphere central axis */
  60897. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  60898. /** Control will rotate to look at z axis (0, 0, 1) */
  60899. static readonly FACEFORWARD_ORIENTATION: number;
  60900. /** Control will rotate to look at negative z axis (0, 0, -1) */
  60901. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  60902. }
  60903. }
  60904. declare module BABYLON.GUI {
  60905. /**
  60906. * Class used to manage 3D user interface
  60907. * @see http://doc.babylonjs.com/how_to/gui3d
  60908. */
  60909. export class GUI3DManager implements BABYLON.IDisposable {
  60910. private _scene;
  60911. private _sceneDisposeObserver;
  60912. private _utilityLayer;
  60913. private _rootContainer;
  60914. private _pointerObserver;
  60915. private _pointerOutObserver;
  60916. /** @hidden */ private _lastPickedControl: Control3D;
  60917. /** @hidden */ private _lastControlOver: {
  60918. [pointerId: number]: Control3D;
  60919. };
  60920. /** @hidden */ private _lastControlDown: {
  60921. [pointerId: number]: Control3D;
  60922. };
  60923. /**
  60924. * BABYLON.Observable raised when the point picked by the pointer events changed
  60925. */
  60926. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  60927. /** @hidden */ private _sharedMaterials: {
  60928. [key: string]: BABYLON.Material;
  60929. };
  60930. /** Gets the hosting scene */
  60931. readonly scene: BABYLON.Scene;
  60932. /** Gets associated utility layer */
  60933. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  60934. /**
  60935. * Creates a new GUI3DManager
  60936. * @param scene
  60937. */
  60938. constructor(scene?: BABYLON.Scene);
  60939. private _handlePointerOut;
  60940. private _doPicking;
  60941. /**
  60942. * Gets the root container
  60943. */
  60944. readonly rootContainer: Container3D;
  60945. /**
  60946. * Gets a boolean indicating if the given control is in the root child list
  60947. * @param control defines the control to check
  60948. * @returns true if the control is in the root child list
  60949. */
  60950. containsControl(control: Control3D): boolean;
  60951. /**
  60952. * Adds a control to the root child list
  60953. * @param control defines the control to add
  60954. * @returns the current manager
  60955. */
  60956. addControl(control: Control3D): GUI3DManager;
  60957. /**
  60958. * Removes a control from the root child list
  60959. * @param control defines the control to remove
  60960. * @returns the current container
  60961. */
  60962. removeControl(control: Control3D): GUI3DManager;
  60963. /**
  60964. * Releases all associated resources
  60965. */
  60966. dispose(): void;
  60967. }
  60968. }
  60969. declare module BABYLON.GUI {
  60970. /**
  60971. * Class used to transport BABYLON.Vector3 information for pointer events
  60972. */
  60973. export class Vector3WithInfo extends BABYLON.Vector3 {
  60974. /** defines the current mouse button index */
  60975. buttonIndex: number;
  60976. /**
  60977. * Creates a new Vector3WithInfo
  60978. * @param source defines the vector3 data to transport
  60979. * @param buttonIndex defines the current mouse button index
  60980. */
  60981. constructor(source: BABYLON.Vector3,
  60982. /** defines the current mouse button index */
  60983. buttonIndex?: number);
  60984. }
  60985. }
  60986. declare module BABYLON.GUI {
  60987. /**
  60988. * Class used as base class for controls
  60989. */
  60990. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  60991. /** Defines the control name */
  60992. name?: string | undefined;
  60993. /** @hidden */ private _host: GUI3DManager;
  60994. private _node;
  60995. private _downCount;
  60996. private _enterCount;
  60997. private _downPointerIds;
  60998. private _isVisible;
  60999. /** Gets or sets the control position in world space */
  61000. position: BABYLON.Vector3;
  61001. /** Gets or sets the control scaling in world space */
  61002. scaling: BABYLON.Vector3;
  61003. /** Callback used to start pointer enter animation */
  61004. pointerEnterAnimation: () => void;
  61005. /** Callback used to start pointer out animation */
  61006. pointerOutAnimation: () => void;
  61007. /** Callback used to start pointer down animation */
  61008. pointerDownAnimation: () => void;
  61009. /** Callback used to start pointer up animation */
  61010. pointerUpAnimation: () => void;
  61011. /**
  61012. * An event triggered when the pointer move over the control
  61013. */
  61014. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  61015. /**
  61016. * An event triggered when the pointer move out of the control
  61017. */
  61018. onPointerOutObservable: BABYLON.Observable<Control3D>;
  61019. /**
  61020. * An event triggered when the pointer taps the control
  61021. */
  61022. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  61023. /**
  61024. * An event triggered when pointer is up
  61025. */
  61026. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  61027. /**
  61028. * An event triggered when a control is clicked on (with a mouse)
  61029. */
  61030. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  61031. /**
  61032. * An event triggered when pointer enters the control
  61033. */
  61034. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  61035. /**
  61036. * Gets or sets the parent container
  61037. */
  61038. parent: BABYLON.Nullable<Container3D>;
  61039. private _behaviors;
  61040. /**
  61041. * Gets the list of attached behaviors
  61042. * @see http://doc.babylonjs.com/features/behaviour
  61043. */
  61044. readonly behaviors: BABYLON.Behavior<Control3D>[];
  61045. /**
  61046. * Attach a behavior to the control
  61047. * @see http://doc.babylonjs.com/features/behaviour
  61048. * @param behavior defines the behavior to attach
  61049. * @returns the current control
  61050. */
  61051. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  61052. /**
  61053. * Remove an attached behavior
  61054. * @see http://doc.babylonjs.com/features/behaviour
  61055. * @param behavior defines the behavior to attach
  61056. * @returns the current control
  61057. */
  61058. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  61059. /**
  61060. * Gets an attached behavior by name
  61061. * @param name defines the name of the behavior to look for
  61062. * @see http://doc.babylonjs.com/features/behaviour
  61063. * @returns null if behavior was not found else the requested behavior
  61064. */
  61065. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  61066. /** Gets or sets a boolean indicating if the control is visible */
  61067. isVisible: boolean;
  61068. /**
  61069. * Creates a new control
  61070. * @param name defines the control name
  61071. */
  61072. constructor(
  61073. /** Defines the control name */
  61074. name?: string | undefined);
  61075. /**
  61076. * Gets a string representing the class name
  61077. */
  61078. readonly typeName: string;
  61079. /**
  61080. * Get the current class name of the control.
  61081. * @returns current class name
  61082. */
  61083. getClassName(): string;
  61084. protected _getTypeName(): string;
  61085. /**
  61086. * Gets the transform node used by this control
  61087. */
  61088. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  61089. /**
  61090. * Gets the mesh used to render this control
  61091. */
  61092. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61093. /**
  61094. * Link the control as child of the given node
  61095. * @param node defines the node to link to. Use null to unlink the control
  61096. * @returns the current control
  61097. */
  61098. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  61099. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  61100. /**
  61101. * Node creation.
  61102. * Can be overriden by children
  61103. * @param scene defines the scene where the node must be attached
  61104. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  61105. */
  61106. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61107. /**
  61108. * Affect a material to the given mesh
  61109. * @param mesh defines the mesh which will represent the control
  61110. */
  61111. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61112. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  61113. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  61114. /** @hidden */ private _onPointerOut(target: Control3D): void;
  61115. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  61116. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61117. /** @hidden */
  61118. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61119. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  61120. /** @hidden */ private _disposeNode(): void;
  61121. /**
  61122. * Releases all associated resources
  61123. */
  61124. dispose(): void;
  61125. }
  61126. }
  61127. declare module BABYLON.GUI {
  61128. /**
  61129. * Class used as a root to all buttons
  61130. */
  61131. export class AbstractButton3D extends Control3D {
  61132. /**
  61133. * Creates a new button
  61134. * @param name defines the control name
  61135. */
  61136. constructor(name?: string);
  61137. protected _getTypeName(): string;
  61138. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61139. }
  61140. }
  61141. declare module BABYLON.GUI {
  61142. /**
  61143. * Class used to create a button in 3D
  61144. */
  61145. export class Button3D extends AbstractButton3D {
  61146. /** @hidden */
  61147. protected _currentMaterial: BABYLON.Material;
  61148. private _facadeTexture;
  61149. private _content;
  61150. private _contentResolution;
  61151. private _contentScaleRatio;
  61152. /**
  61153. * Gets or sets the texture resolution used to render content (512 by default)
  61154. */
  61155. contentResolution: BABYLON.int;
  61156. /**
  61157. * Gets or sets the texture scale ratio used to render content (2 by default)
  61158. */
  61159. contentScaleRatio: number;
  61160. protected _disposeFacadeTexture(): void;
  61161. protected _resetContent(): void;
  61162. /**
  61163. * Creates a new button
  61164. * @param name defines the control name
  61165. */
  61166. constructor(name?: string);
  61167. /**
  61168. * Gets or sets the GUI 2D content used to display the button's facade
  61169. */
  61170. content: Control;
  61171. /**
  61172. * Apply the facade texture (created from the content property).
  61173. * This function can be overloaded by child classes
  61174. * @param facadeTexture defines the AdvancedDynamicTexture to use
  61175. */
  61176. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  61177. protected _getTypeName(): string;
  61178. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61179. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61180. /**
  61181. * Releases all associated resources
  61182. */
  61183. dispose(): void;
  61184. }
  61185. }
  61186. declare module BABYLON.GUI {
  61187. /**
  61188. * Abstract class used to create a container panel deployed on the surface of a volume
  61189. */
  61190. export abstract class VolumeBasedPanel extends Container3D {
  61191. private _columns;
  61192. private _rows;
  61193. private _rowThenColum;
  61194. private _orientation;
  61195. protected _cellWidth: number;
  61196. protected _cellHeight: number;
  61197. /**
  61198. * Gets or sets the distance between elements
  61199. */
  61200. margin: number;
  61201. /**
  61202. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  61203. * | Value | Type | Description |
  61204. * | ----- | ----------------------------------- | ----------- |
  61205. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  61206. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  61207. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  61208. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  61209. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  61210. */
  61211. orientation: number;
  61212. /**
  61213. * Gets or sets the number of columns requested (10 by default).
  61214. * The panel will automatically compute the number of rows based on number of child controls.
  61215. */
  61216. columns: BABYLON.int;
  61217. /**
  61218. * Gets or sets a the number of rows requested.
  61219. * The panel will automatically compute the number of columns based on number of child controls.
  61220. */
  61221. rows: BABYLON.int;
  61222. /**
  61223. * Creates new VolumeBasedPanel
  61224. */
  61225. constructor();
  61226. protected _arrangeChildren(): void;
  61227. /** Child classes must implement this function to provide correct control positioning */
  61228. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61229. /** Child classes can implement this function to provide additional processing */
  61230. protected _finalProcessing(): void;
  61231. }
  61232. }
  61233. declare module BABYLON.GUI {
  61234. /**
  61235. * Class used to create a container panel deployed on the surface of a cylinder
  61236. */
  61237. export class CylinderPanel extends VolumeBasedPanel {
  61238. private _radius;
  61239. /**
  61240. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  61241. */
  61242. radius: BABYLON.float;
  61243. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61244. private _cylindricalMapping;
  61245. }
  61246. }
  61247. declare module BABYLON.GUI {
  61248. /** @hidden */
  61249. export var fluentVertexShader: {
  61250. name: string;
  61251. shader: string;
  61252. };
  61253. }
  61254. declare module BABYLON.GUI {
  61255. /** @hidden */
  61256. export var fluentPixelShader: {
  61257. name: string;
  61258. shader: string;
  61259. };
  61260. }
  61261. declare module BABYLON.GUI {
  61262. /** @hidden */
  61263. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  61264. INNERGLOW: boolean;
  61265. BORDER: boolean;
  61266. HOVERLIGHT: boolean;
  61267. TEXTURE: boolean;
  61268. constructor();
  61269. }
  61270. /**
  61271. * Class used to render controls with fluent desgin
  61272. */
  61273. export class FluentMaterial extends BABYLON.PushMaterial {
  61274. /**
  61275. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  61276. */
  61277. innerGlowColorIntensity: number;
  61278. /**
  61279. * Gets or sets the inner glow color (white by default)
  61280. */
  61281. innerGlowColor: BABYLON.Color3;
  61282. /**
  61283. * Gets or sets alpha value (default is 1.0)
  61284. */
  61285. alpha: number;
  61286. /**
  61287. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  61288. */
  61289. albedoColor: BABYLON.Color3;
  61290. /**
  61291. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  61292. */
  61293. renderBorders: boolean;
  61294. /**
  61295. * Gets or sets border width (default is 0.5)
  61296. */
  61297. borderWidth: number;
  61298. /**
  61299. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  61300. */
  61301. edgeSmoothingValue: number;
  61302. /**
  61303. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  61304. */
  61305. borderMinValue: number;
  61306. /**
  61307. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  61308. */
  61309. renderHoverLight: boolean;
  61310. /**
  61311. * Gets or sets the radius used to render the hover light (default is 1.0)
  61312. */
  61313. hoverRadius: number;
  61314. /**
  61315. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  61316. */
  61317. hoverColor: BABYLON.Color4;
  61318. /**
  61319. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  61320. */
  61321. hoverPosition: BABYLON.Vector3;
  61322. private _albedoTexture;
  61323. /** Gets or sets the texture to use for albedo color */
  61324. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  61325. /**
  61326. * Creates a new Fluent material
  61327. * @param name defines the name of the material
  61328. * @param scene defines the hosting scene
  61329. */
  61330. constructor(name: string, scene: BABYLON.Scene);
  61331. needAlphaBlending(): boolean;
  61332. needAlphaTesting(): boolean;
  61333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61336. getActiveTextures(): BABYLON.BaseTexture[];
  61337. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61338. dispose(forceDisposeEffect?: boolean): void;
  61339. clone(name: string): FluentMaterial;
  61340. serialize(): any;
  61341. getClassName(): string;
  61342. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  61343. }
  61344. }
  61345. declare module BABYLON.GUI {
  61346. /**
  61347. * Class used to create a holographic button in 3D
  61348. */
  61349. export class HolographicButton extends Button3D {
  61350. private _backPlate;
  61351. private _textPlate;
  61352. private _frontPlate;
  61353. private _text;
  61354. private _imageUrl;
  61355. private _shareMaterials;
  61356. private _frontMaterial;
  61357. private _backMaterial;
  61358. private _plateMaterial;
  61359. private _pickedPointObserver;
  61360. private _tooltipFade;
  61361. private _tooltipTextBlock;
  61362. private _tooltipTexture;
  61363. private _tooltipMesh;
  61364. private _tooltipHoverObserver;
  61365. private _tooltipOutObserver;
  61366. private _disposeTooltip;
  61367. /**
  61368. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  61369. */
  61370. tooltipText: BABYLON.Nullable<string>;
  61371. /**
  61372. * Gets or sets text for the button
  61373. */
  61374. text: string;
  61375. /**
  61376. * Gets or sets the image url for the button
  61377. */
  61378. imageUrl: string;
  61379. /**
  61380. * Gets the back material used by this button
  61381. */
  61382. readonly backMaterial: FluentMaterial;
  61383. /**
  61384. * Gets the front material used by this button
  61385. */
  61386. readonly frontMaterial: FluentMaterial;
  61387. /**
  61388. * Gets the plate material used by this button
  61389. */
  61390. readonly plateMaterial: BABYLON.StandardMaterial;
  61391. /**
  61392. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  61393. */
  61394. readonly shareMaterials: boolean;
  61395. /**
  61396. * Creates a new button
  61397. * @param name defines the control name
  61398. */
  61399. constructor(name?: string, shareMaterials?: boolean);
  61400. protected _getTypeName(): string;
  61401. private _rebuildContent;
  61402. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61403. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  61404. private _createBackMaterial;
  61405. private _createFrontMaterial;
  61406. private _createPlateMaterial;
  61407. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  61408. /**
  61409. * Releases all associated resources
  61410. */
  61411. dispose(): void;
  61412. }
  61413. }
  61414. declare module BABYLON.GUI {
  61415. /**
  61416. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  61417. */
  61418. export class MeshButton3D extends Button3D {
  61419. /** @hidden */
  61420. protected _currentMesh: BABYLON.Mesh;
  61421. /**
  61422. * Creates a new 3D button based on a mesh
  61423. * @param mesh mesh to become a 3D button
  61424. * @param name defines the control name
  61425. */
  61426. constructor(mesh: BABYLON.Mesh, name?: string);
  61427. protected _getTypeName(): string;
  61428. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61429. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61430. }
  61431. }
  61432. declare module BABYLON.GUI {
  61433. /**
  61434. * Class used to create a container panel deployed on the surface of a plane
  61435. */
  61436. export class PlanePanel extends VolumeBasedPanel {
  61437. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61438. }
  61439. }
  61440. declare module BABYLON.GUI {
  61441. /**
  61442. * Class used to create a container panel where items get randomized planar mapping
  61443. */
  61444. export class ScatterPanel extends VolumeBasedPanel {
  61445. private _iteration;
  61446. /**
  61447. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  61448. */
  61449. iteration: BABYLON.float;
  61450. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61451. private _scatterMapping;
  61452. protected _finalProcessing(): void;
  61453. }
  61454. }
  61455. declare module BABYLON.GUI {
  61456. /**
  61457. * Class used to create a container panel deployed on the surface of a sphere
  61458. */
  61459. export class SpherePanel extends VolumeBasedPanel {
  61460. private _radius;
  61461. /**
  61462. * Gets or sets the radius of the sphere where to project controls (5 by default)
  61463. */
  61464. radius: BABYLON.float;
  61465. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61466. private _sphericalMapping;
  61467. }
  61468. }
  61469. declare module BABYLON.GUI {
  61470. /**
  61471. * Class used to create a stack panel in 3D on XY plane
  61472. */
  61473. export class StackPanel3D extends Container3D {
  61474. private _isVertical;
  61475. /**
  61476. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  61477. */
  61478. isVertical: boolean;
  61479. /**
  61480. * Gets or sets the distance between elements
  61481. */
  61482. margin: number;
  61483. /**
  61484. * Creates new StackPanel
  61485. * @param isVertical
  61486. */
  61487. constructor(isVertical?: boolean);
  61488. protected _arrangeChildren(): void;
  61489. }
  61490. }
  61491. declare module BABYLON {
  61492. /**
  61493. * Mode that determines the coordinate system to use.
  61494. */
  61495. export enum GLTFLoaderCoordinateSystemMode {
  61496. /**
  61497. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  61498. */
  61499. AUTO = 0,
  61500. /**
  61501. * Sets the useRightHandedSystem flag on the scene.
  61502. */
  61503. FORCE_RIGHT_HANDED = 1
  61504. }
  61505. /**
  61506. * Mode that determines what animations will start.
  61507. */
  61508. export enum GLTFLoaderAnimationStartMode {
  61509. /**
  61510. * No animation will start.
  61511. */
  61512. NONE = 0,
  61513. /**
  61514. * The first animation will start.
  61515. */
  61516. FIRST = 1,
  61517. /**
  61518. * All animations will start.
  61519. */
  61520. ALL = 2
  61521. }
  61522. /**
  61523. * Interface that contains the data for the glTF asset.
  61524. */
  61525. export interface IGLTFLoaderData {
  61526. /**
  61527. * Object that represents the glTF JSON.
  61528. */
  61529. json: Object;
  61530. /**
  61531. * The BIN chunk of a binary glTF.
  61532. */
  61533. bin: Nullable<ArrayBufferView>;
  61534. }
  61535. /**
  61536. * Interface for extending the loader.
  61537. */
  61538. export interface IGLTFLoaderExtension {
  61539. /**
  61540. * The name of this extension.
  61541. */
  61542. readonly name: string;
  61543. /**
  61544. * Defines whether this extension is enabled.
  61545. */
  61546. enabled: boolean;
  61547. }
  61548. /**
  61549. * Loader state.
  61550. */
  61551. export enum GLTFLoaderState {
  61552. /**
  61553. * The asset is loading.
  61554. */
  61555. LOADING = 0,
  61556. /**
  61557. * The asset is ready for rendering.
  61558. */
  61559. READY = 1,
  61560. /**
  61561. * The asset is completely loaded.
  61562. */
  61563. COMPLETE = 2
  61564. }
  61565. /** @hidden */
  61566. export interface IGLTFLoader extends IDisposable {
  61567. readonly state: Nullable<GLTFLoaderState>;
  61568. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  61569. meshes: AbstractMesh[];
  61570. particleSystems: IParticleSystem[];
  61571. skeletons: Skeleton[];
  61572. animationGroups: AnimationGroup[];
  61573. }>;
  61574. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  61575. }
  61576. /**
  61577. * File loader for loading glTF files into a scene.
  61578. */
  61579. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61580. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  61581. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  61582. /**
  61583. * Raised when the asset has been parsed
  61584. */
  61585. onParsedObservable: Observable<IGLTFLoaderData>;
  61586. private _onParsedObserver;
  61587. /**
  61588. * Raised when the asset has been parsed
  61589. */
  61590. onParsed: (loaderData: IGLTFLoaderData) => void;
  61591. /**
  61592. * 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.
  61593. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  61594. * Defaults to true.
  61595. * @hidden
  61596. */
  61597. static IncrementalLoading: boolean;
  61598. /**
  61599. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  61600. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  61601. * @hidden
  61602. */
  61603. static HomogeneousCoordinates: boolean;
  61604. /**
  61605. * The coordinate system mode. Defaults to AUTO.
  61606. */
  61607. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  61608. /**
  61609. * The animation start mode. Defaults to FIRST.
  61610. */
  61611. animationStartMode: GLTFLoaderAnimationStartMode;
  61612. /**
  61613. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  61614. */
  61615. compileMaterials: boolean;
  61616. /**
  61617. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  61618. */
  61619. useClipPlane: boolean;
  61620. /**
  61621. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  61622. */
  61623. compileShadowGenerators: boolean;
  61624. /**
  61625. * Defines if the Alpha blended materials are only applied as coverage.
  61626. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  61627. * If true, no extra effects are applied to transparent pixels.
  61628. */
  61629. transparencyAsCoverage: boolean;
  61630. /**
  61631. * Function called before loading a url referenced by the asset.
  61632. */
  61633. preprocessUrlAsync: (url: string) => Promise<string>;
  61634. /**
  61635. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  61636. */
  61637. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  61638. private _onMeshLoadedObserver;
  61639. /**
  61640. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  61641. */
  61642. onMeshLoaded: (mesh: AbstractMesh) => void;
  61643. /**
  61644. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  61645. */
  61646. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  61647. private _onTextureLoadedObserver;
  61648. /**
  61649. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  61650. */
  61651. onTextureLoaded: (texture: BaseTexture) => void;
  61652. /**
  61653. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  61654. */
  61655. readonly onMaterialLoadedObservable: Observable<Material>;
  61656. private _onMaterialLoadedObserver;
  61657. /**
  61658. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  61659. */
  61660. onMaterialLoaded: (material: Material) => void;
  61661. /**
  61662. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  61663. */
  61664. readonly onCameraLoadedObservable: Observable<Camera>;
  61665. private _onCameraLoadedObserver;
  61666. /**
  61667. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  61668. */
  61669. onCameraLoaded: (camera: Camera) => void;
  61670. /**
  61671. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  61672. * For assets with LODs, raised when all of the LODs are complete.
  61673. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  61674. */
  61675. readonly onCompleteObservable: Observable<void>;
  61676. private _onCompleteObserver;
  61677. /**
  61678. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  61679. * For assets with LODs, raised when all of the LODs are complete.
  61680. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  61681. */
  61682. onComplete: () => void;
  61683. /**
  61684. * Observable raised when an error occurs.
  61685. */
  61686. readonly onErrorObservable: Observable<any>;
  61687. private _onErrorObserver;
  61688. /**
  61689. * Callback raised when an error occurs.
  61690. */
  61691. onError: (reason: any) => void;
  61692. /**
  61693. * Observable raised after the loader is disposed.
  61694. */
  61695. readonly onDisposeObservable: Observable<void>;
  61696. private _onDisposeObserver;
  61697. /**
  61698. * Callback raised after the loader is disposed.
  61699. */
  61700. onDispose: () => void;
  61701. /**
  61702. * Observable raised after a loader extension is created.
  61703. * Set additional options for a loader extension in this event.
  61704. */
  61705. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  61706. private _onExtensionLoadedObserver;
  61707. /**
  61708. * Callback raised after a loader extension is created.
  61709. */
  61710. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  61711. /**
  61712. * Defines if the loader logging is enabled.
  61713. */
  61714. loggingEnabled: boolean;
  61715. /**
  61716. * Defines if the loader should capture performance counters.
  61717. */
  61718. capturePerformanceCounters: boolean;
  61719. /**
  61720. * Defines if the loader should validate the asset.
  61721. */
  61722. validate: boolean;
  61723. /**
  61724. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  61725. */
  61726. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  61727. private _onValidatedObserver;
  61728. /**
  61729. * Callback raised after a loader extension is created.
  61730. */
  61731. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  61732. private _loader;
  61733. /**
  61734. * Name of the loader ("gltf")
  61735. */
  61736. name: string;
  61737. /**
  61738. * Supported file extensions of the loader (.gltf, .glb)
  61739. */
  61740. extensions: ISceneLoaderPluginExtensions;
  61741. /**
  61742. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  61743. */
  61744. dispose(): void;
  61745. /** @hidden */ private _clear(): void;
  61746. /**
  61747. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  61748. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61749. * @param scene the scene the meshes should be added to
  61750. * @param data the glTF data to load
  61751. * @param rootUrl root url to load from
  61752. * @param onProgress event that fires when loading progress has occured
  61753. * @param fileName Defines the name of the file to load
  61754. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61755. */
  61756. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61757. meshes: AbstractMesh[];
  61758. particleSystems: IParticleSystem[];
  61759. skeletons: Skeleton[];
  61760. animationGroups: AnimationGroup[];
  61761. }>;
  61762. /**
  61763. * Imports all objects from the loaded glTF data and adds them to the scene
  61764. * @param scene the scene the objects should be added to
  61765. * @param data the glTF data to load
  61766. * @param rootUrl root url to load from
  61767. * @param onProgress event that fires when loading progress has occured
  61768. * @param fileName Defines the name of the file to load
  61769. * @returns a promise which completes when objects have been loaded to the scene
  61770. */
  61771. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61772. /**
  61773. * Load into an asset container.
  61774. * @param scene The scene to load into
  61775. * @param data The data to import
  61776. * @param rootUrl The root url for scene and resources
  61777. * @param onProgress The callback when the load progresses
  61778. * @param fileName Defines the name of the file to load
  61779. * @returns The loaded asset container
  61780. */
  61781. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61782. /**
  61783. * If the data string can be loaded directly.
  61784. * @param data string contianing the file data
  61785. * @returns if the data can be loaded directly
  61786. */
  61787. canDirectLoad(data: string): boolean;
  61788. /**
  61789. * Rewrites a url by combining a root url and response url.
  61790. */
  61791. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  61792. /**
  61793. * Instantiates a glTF file loader plugin.
  61794. * @returns the created plugin
  61795. */
  61796. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  61797. /**
  61798. * The loader state or null if the loader is not active.
  61799. */
  61800. readonly loaderState: Nullable<GLTFLoaderState>;
  61801. /**
  61802. * Returns a promise that resolves when the asset is completely loaded.
  61803. * @returns a promise that resolves when the asset is completely loaded.
  61804. */
  61805. whenCompleteAsync(): Promise<void>;
  61806. private _parseAsync;
  61807. private _validateAsync;
  61808. private _getLoader;
  61809. private _unpackBinary;
  61810. private _unpackBinaryV1;
  61811. private _unpackBinaryV2;
  61812. private static _parseVersion;
  61813. private static _compareVersion;
  61814. private static _decodeBufferToText;
  61815. private static readonly _logSpaces;
  61816. private _logIndentLevel;
  61817. private _loggingEnabled;
  61818. /** @hidden */ private _log: (message: string) => void;
  61819. /** @hidden */ private _logOpen(message: string): void;
  61820. /** @hidden */ private _logClose(): void;
  61821. private _logEnabled;
  61822. private _logDisabled;
  61823. private _capturePerformanceCounters;
  61824. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  61825. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  61826. private _startPerformanceCounterEnabled;
  61827. private _startPerformanceCounterDisabled;
  61828. private _endPerformanceCounterEnabled;
  61829. private _endPerformanceCounterDisabled;
  61830. }
  61831. }
  61832. declare module BABYLON.GLTF1 {
  61833. /**
  61834. * Enums
  61835. * @hidden
  61836. */
  61837. export enum EComponentType {
  61838. BYTE = 5120,
  61839. UNSIGNED_BYTE = 5121,
  61840. SHORT = 5122,
  61841. UNSIGNED_SHORT = 5123,
  61842. FLOAT = 5126
  61843. }
  61844. /** @hidden */
  61845. export enum EShaderType {
  61846. FRAGMENT = 35632,
  61847. VERTEX = 35633
  61848. }
  61849. /** @hidden */
  61850. export enum EParameterType {
  61851. BYTE = 5120,
  61852. UNSIGNED_BYTE = 5121,
  61853. SHORT = 5122,
  61854. UNSIGNED_SHORT = 5123,
  61855. INT = 5124,
  61856. UNSIGNED_INT = 5125,
  61857. FLOAT = 5126,
  61858. FLOAT_VEC2 = 35664,
  61859. FLOAT_VEC3 = 35665,
  61860. FLOAT_VEC4 = 35666,
  61861. INT_VEC2 = 35667,
  61862. INT_VEC3 = 35668,
  61863. INT_VEC4 = 35669,
  61864. BOOL = 35670,
  61865. BOOL_VEC2 = 35671,
  61866. BOOL_VEC3 = 35672,
  61867. BOOL_VEC4 = 35673,
  61868. FLOAT_MAT2 = 35674,
  61869. FLOAT_MAT3 = 35675,
  61870. FLOAT_MAT4 = 35676,
  61871. SAMPLER_2D = 35678
  61872. }
  61873. /** @hidden */
  61874. export enum ETextureWrapMode {
  61875. CLAMP_TO_EDGE = 33071,
  61876. MIRRORED_REPEAT = 33648,
  61877. REPEAT = 10497
  61878. }
  61879. /** @hidden */
  61880. export enum ETextureFilterType {
  61881. NEAREST = 9728,
  61882. LINEAR = 9728,
  61883. NEAREST_MIPMAP_NEAREST = 9984,
  61884. LINEAR_MIPMAP_NEAREST = 9985,
  61885. NEAREST_MIPMAP_LINEAR = 9986,
  61886. LINEAR_MIPMAP_LINEAR = 9987
  61887. }
  61888. /** @hidden */
  61889. export enum ETextureFormat {
  61890. ALPHA = 6406,
  61891. RGB = 6407,
  61892. RGBA = 6408,
  61893. LUMINANCE = 6409,
  61894. LUMINANCE_ALPHA = 6410
  61895. }
  61896. /** @hidden */
  61897. export enum ECullingType {
  61898. FRONT = 1028,
  61899. BACK = 1029,
  61900. FRONT_AND_BACK = 1032
  61901. }
  61902. /** @hidden */
  61903. export enum EBlendingFunction {
  61904. ZERO = 0,
  61905. ONE = 1,
  61906. SRC_COLOR = 768,
  61907. ONE_MINUS_SRC_COLOR = 769,
  61908. DST_COLOR = 774,
  61909. ONE_MINUS_DST_COLOR = 775,
  61910. SRC_ALPHA = 770,
  61911. ONE_MINUS_SRC_ALPHA = 771,
  61912. DST_ALPHA = 772,
  61913. ONE_MINUS_DST_ALPHA = 773,
  61914. CONSTANT_COLOR = 32769,
  61915. ONE_MINUS_CONSTANT_COLOR = 32770,
  61916. CONSTANT_ALPHA = 32771,
  61917. ONE_MINUS_CONSTANT_ALPHA = 32772,
  61918. SRC_ALPHA_SATURATE = 776
  61919. }
  61920. /** @hidden */
  61921. export interface IGLTFProperty {
  61922. extensions?: {
  61923. [key: string]: any;
  61924. };
  61925. extras?: Object;
  61926. }
  61927. /** @hidden */
  61928. export interface IGLTFChildRootProperty extends IGLTFProperty {
  61929. name?: string;
  61930. }
  61931. /** @hidden */
  61932. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  61933. bufferView: string;
  61934. byteOffset: number;
  61935. byteStride: number;
  61936. count: number;
  61937. type: string;
  61938. componentType: EComponentType;
  61939. max?: number[];
  61940. min?: number[];
  61941. name?: string;
  61942. }
  61943. /** @hidden */
  61944. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  61945. buffer: string;
  61946. byteOffset: number;
  61947. byteLength: number;
  61948. byteStride: number;
  61949. target?: number;
  61950. }
  61951. /** @hidden */
  61952. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  61953. uri: string;
  61954. byteLength?: number;
  61955. type?: string;
  61956. }
  61957. /** @hidden */
  61958. export interface IGLTFShader extends IGLTFChildRootProperty {
  61959. uri: string;
  61960. type: EShaderType;
  61961. }
  61962. /** @hidden */
  61963. export interface IGLTFProgram extends IGLTFChildRootProperty {
  61964. attributes: string[];
  61965. fragmentShader: string;
  61966. vertexShader: string;
  61967. }
  61968. /** @hidden */
  61969. export interface IGLTFTechniqueParameter {
  61970. type: number;
  61971. count?: number;
  61972. semantic?: string;
  61973. node?: string;
  61974. value?: number | boolean | string | Array<any>;
  61975. source?: string;
  61976. babylonValue?: any;
  61977. }
  61978. /** @hidden */
  61979. export interface IGLTFTechniqueCommonProfile {
  61980. lightingModel: string;
  61981. texcoordBindings: Object;
  61982. parameters?: Array<any>;
  61983. }
  61984. /** @hidden */
  61985. export interface IGLTFTechniqueStatesFunctions {
  61986. blendColor?: number[];
  61987. blendEquationSeparate?: number[];
  61988. blendFuncSeparate?: number[];
  61989. colorMask: boolean[];
  61990. cullFace: number[];
  61991. }
  61992. /** @hidden */
  61993. export interface IGLTFTechniqueStates {
  61994. enable: number[];
  61995. functions: IGLTFTechniqueStatesFunctions;
  61996. }
  61997. /** @hidden */
  61998. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  61999. parameters: {
  62000. [key: string]: IGLTFTechniqueParameter;
  62001. };
  62002. program: string;
  62003. attributes: {
  62004. [key: string]: string;
  62005. };
  62006. uniforms: {
  62007. [key: string]: string;
  62008. };
  62009. states: IGLTFTechniqueStates;
  62010. }
  62011. /** @hidden */
  62012. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  62013. technique?: string;
  62014. values: string[];
  62015. }
  62016. /** @hidden */
  62017. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  62018. attributes: {
  62019. [key: string]: string;
  62020. };
  62021. indices: string;
  62022. material: string;
  62023. mode?: number;
  62024. }
  62025. /** @hidden */
  62026. export interface IGLTFMesh extends IGLTFChildRootProperty {
  62027. primitives: IGLTFMeshPrimitive[];
  62028. }
  62029. /** @hidden */
  62030. export interface IGLTFImage extends IGLTFChildRootProperty {
  62031. uri: string;
  62032. }
  62033. /** @hidden */
  62034. export interface IGLTFSampler extends IGLTFChildRootProperty {
  62035. magFilter?: number;
  62036. minFilter?: number;
  62037. wrapS?: number;
  62038. wrapT?: number;
  62039. }
  62040. /** @hidden */
  62041. export interface IGLTFTexture extends IGLTFChildRootProperty {
  62042. sampler: string;
  62043. source: string;
  62044. format?: ETextureFormat;
  62045. internalFormat?: ETextureFormat;
  62046. target?: number;
  62047. type?: number;
  62048. babylonTexture?: Texture;
  62049. }
  62050. /** @hidden */
  62051. export interface IGLTFAmbienLight {
  62052. color?: number[];
  62053. }
  62054. /** @hidden */
  62055. export interface IGLTFDirectionalLight {
  62056. color?: number[];
  62057. }
  62058. /** @hidden */
  62059. export interface IGLTFPointLight {
  62060. color?: number[];
  62061. constantAttenuation?: number;
  62062. linearAttenuation?: number;
  62063. quadraticAttenuation?: number;
  62064. }
  62065. /** @hidden */
  62066. export interface IGLTFSpotLight {
  62067. color?: number[];
  62068. constantAttenuation?: number;
  62069. fallOfAngle?: number;
  62070. fallOffExponent?: number;
  62071. linearAttenuation?: number;
  62072. quadraticAttenuation?: number;
  62073. }
  62074. /** @hidden */
  62075. export interface IGLTFLight extends IGLTFChildRootProperty {
  62076. type: string;
  62077. }
  62078. /** @hidden */
  62079. export interface IGLTFCameraOrthographic {
  62080. xmag: number;
  62081. ymag: number;
  62082. zfar: number;
  62083. znear: number;
  62084. }
  62085. /** @hidden */
  62086. export interface IGLTFCameraPerspective {
  62087. aspectRatio: number;
  62088. yfov: number;
  62089. zfar: number;
  62090. znear: number;
  62091. }
  62092. /** @hidden */
  62093. export interface IGLTFCamera extends IGLTFChildRootProperty {
  62094. type: string;
  62095. }
  62096. /** @hidden */
  62097. export interface IGLTFAnimationChannelTarget {
  62098. id: string;
  62099. path: string;
  62100. }
  62101. /** @hidden */
  62102. export interface IGLTFAnimationChannel {
  62103. sampler: string;
  62104. target: IGLTFAnimationChannelTarget;
  62105. }
  62106. /** @hidden */
  62107. export interface IGLTFAnimationSampler {
  62108. input: string;
  62109. output: string;
  62110. interpolation?: string;
  62111. }
  62112. /** @hidden */
  62113. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  62114. channels?: IGLTFAnimationChannel[];
  62115. parameters?: {
  62116. [key: string]: string;
  62117. };
  62118. samplers?: {
  62119. [key: string]: IGLTFAnimationSampler;
  62120. };
  62121. }
  62122. /** @hidden */
  62123. export interface IGLTFNodeInstanceSkin {
  62124. skeletons: string[];
  62125. skin: string;
  62126. meshes: string[];
  62127. }
  62128. /** @hidden */
  62129. export interface IGLTFSkins extends IGLTFChildRootProperty {
  62130. bindShapeMatrix: number[];
  62131. inverseBindMatrices: string;
  62132. jointNames: string[];
  62133. babylonSkeleton?: Skeleton;
  62134. }
  62135. /** @hidden */
  62136. export interface IGLTFNode extends IGLTFChildRootProperty {
  62137. camera?: string;
  62138. children: string[];
  62139. skin?: string;
  62140. jointName?: string;
  62141. light?: string;
  62142. matrix: number[];
  62143. mesh?: string;
  62144. meshes?: string[];
  62145. rotation?: number[];
  62146. scale?: number[];
  62147. translation?: number[];
  62148. babylonNode?: Node;
  62149. }
  62150. /** @hidden */
  62151. export interface IGLTFScene extends IGLTFChildRootProperty {
  62152. nodes: string[];
  62153. }
  62154. /** @hidden */
  62155. export interface IGLTFRuntime {
  62156. extensions: {
  62157. [key: string]: any;
  62158. };
  62159. accessors: {
  62160. [key: string]: IGLTFAccessor;
  62161. };
  62162. buffers: {
  62163. [key: string]: IGLTFBuffer;
  62164. };
  62165. bufferViews: {
  62166. [key: string]: IGLTFBufferView;
  62167. };
  62168. meshes: {
  62169. [key: string]: IGLTFMesh;
  62170. };
  62171. lights: {
  62172. [key: string]: IGLTFLight;
  62173. };
  62174. cameras: {
  62175. [key: string]: IGLTFCamera;
  62176. };
  62177. nodes: {
  62178. [key: string]: IGLTFNode;
  62179. };
  62180. images: {
  62181. [key: string]: IGLTFImage;
  62182. };
  62183. textures: {
  62184. [key: string]: IGLTFTexture;
  62185. };
  62186. shaders: {
  62187. [key: string]: IGLTFShader;
  62188. };
  62189. programs: {
  62190. [key: string]: IGLTFProgram;
  62191. };
  62192. samplers: {
  62193. [key: string]: IGLTFSampler;
  62194. };
  62195. techniques: {
  62196. [key: string]: IGLTFTechnique;
  62197. };
  62198. materials: {
  62199. [key: string]: IGLTFMaterial;
  62200. };
  62201. animations: {
  62202. [key: string]: IGLTFAnimation;
  62203. };
  62204. skins: {
  62205. [key: string]: IGLTFSkins;
  62206. };
  62207. currentScene?: Object;
  62208. scenes: {
  62209. [key: string]: IGLTFScene;
  62210. };
  62211. extensionsUsed: string[];
  62212. extensionsRequired?: string[];
  62213. buffersCount: number;
  62214. shaderscount: number;
  62215. scene: Scene;
  62216. rootUrl: string;
  62217. loadedBufferCount: number;
  62218. loadedBufferViews: {
  62219. [name: string]: ArrayBufferView;
  62220. };
  62221. loadedShaderCount: number;
  62222. importOnlyMeshes: boolean;
  62223. importMeshesNames?: string[];
  62224. dummyNodes: Node[];
  62225. }
  62226. /** @hidden */
  62227. export interface INodeToRoot {
  62228. bone: Bone;
  62229. node: IGLTFNode;
  62230. id: string;
  62231. }
  62232. /** @hidden */
  62233. export interface IJointNode {
  62234. node: IGLTFNode;
  62235. id: string;
  62236. }
  62237. }
  62238. declare module BABYLON.GLTF1 {
  62239. /**
  62240. * Utils functions for GLTF
  62241. * @hidden
  62242. */
  62243. export class GLTFUtils {
  62244. /**
  62245. * Sets the given "parameter" matrix
  62246. * @param scene: the Scene object
  62247. * @param source: the source node where to pick the matrix
  62248. * @param parameter: the GLTF technique parameter
  62249. * @param uniformName: the name of the shader's uniform
  62250. * @param shaderMaterial: the shader material
  62251. */
  62252. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  62253. /**
  62254. * Sets the given "parameter" matrix
  62255. * @param shaderMaterial: the shader material
  62256. * @param uniform: the name of the shader's uniform
  62257. * @param value: the value of the uniform
  62258. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  62259. */
  62260. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  62261. /**
  62262. * Returns the wrap mode of the texture
  62263. * @param mode: the mode value
  62264. */
  62265. static GetWrapMode(mode: number): number;
  62266. /**
  62267. * Returns the byte stride giving an accessor
  62268. * @param accessor: the GLTF accessor objet
  62269. */
  62270. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  62271. /**
  62272. * Returns the texture filter mode giving a mode value
  62273. * @param mode: the filter mode value
  62274. */
  62275. static GetTextureFilterMode(mode: number): ETextureFilterType;
  62276. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  62277. /**
  62278. * Returns a buffer from its accessor
  62279. * @param gltfRuntime: the GLTF runtime
  62280. * @param accessor: the GLTF accessor
  62281. */
  62282. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  62283. /**
  62284. * Decodes a buffer view into a string
  62285. * @param view: the buffer view
  62286. */
  62287. static DecodeBufferToText(view: ArrayBufferView): string;
  62288. /**
  62289. * Returns the default material of gltf. Related to
  62290. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  62291. * @param scene: the Babylon.js scene
  62292. */
  62293. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  62294. private static _DefaultMaterial;
  62295. }
  62296. }
  62297. declare module BABYLON.GLTF1 {
  62298. /**
  62299. * Implementation of the base glTF spec
  62300. * @hidden
  62301. */
  62302. export class GLTFLoaderBase {
  62303. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  62304. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  62305. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  62306. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  62307. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  62308. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  62309. }
  62310. /**
  62311. * glTF V1 Loader
  62312. * @hidden
  62313. */
  62314. export class GLTFLoader implements IGLTFLoader {
  62315. static Extensions: {
  62316. [name: string]: GLTFLoaderExtension;
  62317. };
  62318. static RegisterExtension(extension: GLTFLoaderExtension): void;
  62319. state: Nullable<GLTFLoaderState>;
  62320. dispose(): void;
  62321. private _importMeshAsync;
  62322. /**
  62323. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  62324. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62325. * @param scene the scene the meshes should be added to
  62326. * @param data gltf data containing information of the meshes in a loaded file
  62327. * @param rootUrl root url to load from
  62328. * @param onProgress event that fires when loading progress has occured
  62329. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62330. */
  62331. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  62332. meshes: AbstractMesh[];
  62333. particleSystems: IParticleSystem[];
  62334. skeletons: Skeleton[];
  62335. animationGroups: AnimationGroup[];
  62336. }>;
  62337. private _loadAsync;
  62338. /**
  62339. * Imports all objects from a loaded gltf file and adds them to the scene
  62340. * @param scene the scene the objects should be added to
  62341. * @param data gltf data containing information of the meshes in a loaded file
  62342. * @param rootUrl root url to load from
  62343. * @param onProgress event that fires when loading progress has occured
  62344. * @returns a promise which completes when objects have been loaded to the scene
  62345. */
  62346. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  62347. private _loadShadersAsync;
  62348. private _loadBuffersAsync;
  62349. private _createNodes;
  62350. }
  62351. /** @hidden */
  62352. export abstract class GLTFLoaderExtension {
  62353. private _name;
  62354. constructor(name: string);
  62355. readonly name: string;
  62356. /**
  62357. * Defines an override for loading the runtime
  62358. * Return true to stop further extensions from loading the runtime
  62359. */
  62360. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  62361. /**
  62362. * Defines an onverride for creating gltf runtime
  62363. * Return true to stop further extensions from creating the runtime
  62364. */
  62365. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  62366. /**
  62367. * Defines an override for loading buffers
  62368. * Return true to stop further extensions from loading this buffer
  62369. */
  62370. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  62371. /**
  62372. * Defines an override for loading texture buffers
  62373. * Return true to stop further extensions from loading this texture data
  62374. */
  62375. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  62376. /**
  62377. * Defines an override for creating textures
  62378. * Return true to stop further extensions from loading this texture
  62379. */
  62380. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  62381. /**
  62382. * Defines an override for loading shader strings
  62383. * Return true to stop further extensions from loading this shader data
  62384. */
  62385. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  62386. /**
  62387. * Defines an override for loading materials
  62388. * Return true to stop further extensions from loading this material
  62389. */
  62390. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  62391. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  62392. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  62393. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  62394. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  62395. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  62396. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  62397. private static LoadTextureBufferAsync;
  62398. private static CreateTextureAsync;
  62399. private static ApplyExtensions;
  62400. }
  62401. }
  62402. declare module BABYLON.GLTF1 {
  62403. /** @hidden */
  62404. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  62405. private _bin;
  62406. constructor();
  62407. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  62408. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  62409. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  62410. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  62411. }
  62412. }
  62413. declare module BABYLON.GLTF1 {
  62414. /** @hidden */
  62415. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  62416. constructor();
  62417. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  62418. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  62419. private _loadTexture;
  62420. }
  62421. }
  62422. declare module BABYLON.GLTF2.Loader {
  62423. /**
  62424. * Loader interface with an index field.
  62425. */
  62426. export interface IArrayItem {
  62427. /**
  62428. * The index of this item in the array.
  62429. */
  62430. index: number;
  62431. }
  62432. /**
  62433. * Loader interface with additional members.
  62434. */
  62435. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  62436. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62437. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  62438. }
  62439. /**
  62440. * Loader interface with additional members.
  62441. */
  62442. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  62443. }
  62444. /** @hidden */
  62445. export interface _IAnimationSamplerData {
  62446. input: Float32Array;
  62447. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  62448. output: Float32Array;
  62449. }
  62450. /**
  62451. * Loader interface with additional members.
  62452. */
  62453. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  62454. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  62455. }
  62456. /**
  62457. * Loader interface with additional members.
  62458. */
  62459. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  62460. channels: IAnimationChannel[];
  62461. samplers: IAnimationSampler[];
  62462. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  62463. }
  62464. /**
  62465. * Loader interface with additional members.
  62466. */
  62467. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  62468. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62469. }
  62470. /**
  62471. * Loader interface with additional members.
  62472. */
  62473. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  62474. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62475. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  62476. }
  62477. /**
  62478. * Loader interface with additional members.
  62479. */
  62480. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  62481. }
  62482. /**
  62483. * Loader interface with additional members.
  62484. */
  62485. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  62486. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62487. }
  62488. /**
  62489. * Loader interface with additional members.
  62490. */
  62491. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  62492. }
  62493. /**
  62494. * Loader interface with additional members.
  62495. */
  62496. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  62497. }
  62498. /**
  62499. * Loader interface with additional members.
  62500. */
  62501. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  62502. baseColorTexture?: ITextureInfo;
  62503. metallicRoughnessTexture?: ITextureInfo;
  62504. }
  62505. /**
  62506. * Loader interface with additional members.
  62507. */
  62508. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  62509. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  62510. normalTexture?: IMaterialNormalTextureInfo;
  62511. occlusionTexture?: IMaterialOcclusionTextureInfo;
  62512. emissiveTexture?: ITextureInfo;
  62513. /** @hidden */ private _data?: {
  62514. [babylonDrawMode: number]: {
  62515. babylonMaterial: Material;
  62516. babylonMeshes: AbstractMesh[];
  62517. promise: Promise<void>;
  62518. };
  62519. };
  62520. }
  62521. /**
  62522. * Loader interface with additional members.
  62523. */
  62524. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  62525. primitives: IMeshPrimitive[];
  62526. }
  62527. /**
  62528. * Loader interface with additional members.
  62529. */
  62530. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  62531. /** @hidden */ private _instanceData?: {
  62532. babylonSourceMesh: Mesh;
  62533. promise: Promise<any>;
  62534. };
  62535. }
  62536. /**
  62537. * Loader interface with additional members.
  62538. */
  62539. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  62540. /**
  62541. * The parent glTF node.
  62542. */
  62543. parent?: INode;
  62544. /** @hidden */ private _babylonTransformNode?: TransformNode;
  62545. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  62546. /** @hidden */ private _babylonBones?: Bone[];
  62547. /** @hidden */ private _numMorphTargets?: number;
  62548. }
  62549. /** @hidden */
  62550. export interface _ISamplerData {
  62551. noMipMaps: boolean;
  62552. samplingMode: number;
  62553. wrapU: number;
  62554. wrapV: number;
  62555. }
  62556. /**
  62557. * Loader interface with additional members.
  62558. */
  62559. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  62560. /** @hidden */ private _data?: _ISamplerData;
  62561. }
  62562. /**
  62563. * Loader interface with additional members.
  62564. */
  62565. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  62566. }
  62567. /**
  62568. * Loader interface with additional members.
  62569. */
  62570. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  62571. /** @hidden */ private _data?: {
  62572. babylonSkeleton: Skeleton;
  62573. promise: Promise<void>;
  62574. };
  62575. }
  62576. /**
  62577. * Loader interface with additional members.
  62578. */
  62579. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  62580. }
  62581. /**
  62582. * Loader interface with additional members.
  62583. */
  62584. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  62585. }
  62586. /**
  62587. * Loader interface with additional members.
  62588. */
  62589. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  62590. accessors?: IAccessor[];
  62591. animations?: IAnimation[];
  62592. buffers?: IBuffer[];
  62593. bufferViews?: IBufferView[];
  62594. cameras?: ICamera[];
  62595. images?: IImage[];
  62596. materials?: IMaterial[];
  62597. meshes?: IMesh[];
  62598. nodes?: INode[];
  62599. samplers?: ISampler[];
  62600. scenes?: IScene[];
  62601. skins?: ISkin[];
  62602. textures?: ITexture[];
  62603. }
  62604. }
  62605. declare module BABYLON.GLTF2 {
  62606. /**
  62607. * Interface for a glTF loader extension.
  62608. */
  62609. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  62610. /**
  62611. * Called after the loader state changes to LOADING.
  62612. */
  62613. onLoading?(): void;
  62614. /**
  62615. * Called after the loader state changes to READY.
  62616. */
  62617. onReady?(): void;
  62618. /**
  62619. * Define this method to modify the default behavior when loading scenes.
  62620. * @param context The context when loading the asset
  62621. * @param scene The glTF scene property
  62622. * @returns A promise that resolves when the load is complete or null if not handled
  62623. */
  62624. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  62625. /**
  62626. * Define this method to modify the default behavior when loading nodes.
  62627. * @param context The context when loading the asset
  62628. * @param node The glTF node property
  62629. * @param assign A function called synchronously after parsing the glTF properties
  62630. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  62631. */
  62632. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  62633. /**
  62634. * Define this method to modify the default behavior when loading cameras.
  62635. * @param context The context when loading the asset
  62636. * @param camera The glTF camera property
  62637. * @param assign A function called synchronously after parsing the glTF properties
  62638. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  62639. */
  62640. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  62641. /**
  62642. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  62643. * @param context The context when loading the asset
  62644. * @param primitive The glTF mesh primitive property
  62645. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  62646. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  62647. /**
  62648. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  62649. * @param context The context when loading the asset
  62650. * @param name The mesh name when loading the asset
  62651. * @param node The glTF node when loading the asset
  62652. * @param mesh The glTF mesh when loading the asset
  62653. * @param primitive The glTF mesh primitive property
  62654. * @param assign A function called synchronously after parsing the glTF properties
  62655. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  62656. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  62657. /**
  62658. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  62659. * @param context The context when loading the asset
  62660. * @param material The glTF material property
  62661. * @param assign A function called synchronously after parsing the glTF properties
  62662. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  62663. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  62664. /**
  62665. * Define this method to modify the default behavior when creating materials.
  62666. * @param context The context when loading the asset
  62667. * @param material The glTF material property
  62668. * @param babylonDrawMode The draw mode for the Babylon material
  62669. * @returns The Babylon material or null if not handled
  62670. */
  62671. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  62672. /**
  62673. * Define this method to modify the default behavior when loading material properties.
  62674. * @param context The context when loading the asset
  62675. * @param material The glTF material property
  62676. * @param babylonMaterial The Babylon material
  62677. * @returns A promise that resolves when the load is complete or null if not handled
  62678. */
  62679. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  62680. /**
  62681. * Define this method to modify the default behavior when loading texture infos.
  62682. * @param context The context when loading the asset
  62683. * @param textureInfo The glTF texture info property
  62684. * @param assign A function called synchronously after parsing the glTF properties
  62685. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  62686. */
  62687. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  62688. /**
  62689. * Define this method to modify the default behavior when loading animations.
  62690. * @param context The context when loading the asset
  62691. * @param animation The glTF animation property
  62692. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  62693. */
  62694. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  62695. /**
  62696. * @hidden Define this method to modify the default behavior when loading skins.
  62697. * @param context The context when loading the asset
  62698. * @param node The glTF node property
  62699. * @param skin The glTF skin property
  62700. * @returns A promise that resolves when the load is complete or null if not handled
  62701. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  62702. /**
  62703. * @hidden Define this method to modify the default behavior when loading uris.
  62704. * @param context The context when loading the asset
  62705. * @param property The glTF property associated with the uri
  62706. * @param uri The uri to load
  62707. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  62708. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  62709. }
  62710. }
  62711. declare module BABYLON.GLTF2 {
  62712. /**
  62713. * Helper class for working with arrays when loading the glTF asset
  62714. */
  62715. export class ArrayItem {
  62716. /**
  62717. * Gets an item from the given array.
  62718. * @param context The context when loading the asset
  62719. * @param array The array to get the item from
  62720. * @param index The index to the array
  62721. * @returns The array item
  62722. */
  62723. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  62724. /**
  62725. * Assign an `index` field to each item of the given array.
  62726. * @param array The array of items
  62727. */
  62728. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  62729. }
  62730. /**
  62731. * The glTF 2.0 loader
  62732. */
  62733. export class GLTFLoader implements IGLTFLoader {
  62734. /** @hidden */ private _completePromises: Promise<any>[];
  62735. private _disposed;
  62736. private _parent;
  62737. private _state;
  62738. private _extensions;
  62739. private _rootUrl;
  62740. private _fileName;
  62741. private _uniqueRootUrl;
  62742. private _gltf;
  62743. private _babylonScene;
  62744. private _rootBabylonMesh;
  62745. private _defaultBabylonMaterialData;
  62746. private _progressCallback?;
  62747. private _requests;
  62748. private static readonly _DefaultSampler;
  62749. private static _ExtensionNames;
  62750. private static _ExtensionFactories;
  62751. /**
  62752. * Registers a loader extension.
  62753. * @param name The name of the loader extension.
  62754. * @param factory The factory function that creates the loader extension.
  62755. */
  62756. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  62757. /**
  62758. * Unregisters a loader extension.
  62759. * @param name The name of the loader extenion.
  62760. * @returns A boolean indicating whether the extension has been unregistered
  62761. */
  62762. static UnregisterExtension(name: string): boolean;
  62763. /**
  62764. * Gets the loader state.
  62765. */
  62766. readonly state: Nullable<GLTFLoaderState>;
  62767. /**
  62768. * The glTF object parsed from the JSON.
  62769. */
  62770. readonly gltf: IGLTF;
  62771. /**
  62772. * The Babylon scene when loading the asset.
  62773. */
  62774. readonly babylonScene: Scene;
  62775. /**
  62776. * The root Babylon mesh when loading the asset.
  62777. */
  62778. readonly rootBabylonMesh: Mesh;
  62779. /** @hidden */
  62780. constructor(parent: GLTFFileLoader);
  62781. /** @hidden */
  62782. dispose(): void;
  62783. /** @hidden */
  62784. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62785. meshes: AbstractMesh[];
  62786. particleSystems: IParticleSystem[];
  62787. skeletons: Skeleton[];
  62788. animationGroups: AnimationGroup[];
  62789. }>;
  62790. /** @hidden */
  62791. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62792. private _loadAsync;
  62793. private _loadData;
  62794. private _setupData;
  62795. private _loadExtensions;
  62796. private _checkExtensions;
  62797. private _setState;
  62798. private _createRootNode;
  62799. /**
  62800. * Loads a glTF scene.
  62801. * @param context The context when loading the asset
  62802. * @param scene The glTF scene property
  62803. * @returns A promise that resolves when the load is complete
  62804. */
  62805. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  62806. private _forEachPrimitive;
  62807. private _getMeshes;
  62808. private _getSkeletons;
  62809. private _getAnimationGroups;
  62810. private _startAnimations;
  62811. /**
  62812. * Loads a glTF node.
  62813. * @param context The context when loading the asset
  62814. * @param node The glTF node property
  62815. * @param assign A function called synchronously after parsing the glTF properties
  62816. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  62817. */
  62818. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  62819. private _loadMeshAsync;
  62820. /**
  62821. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  62822. * @param context The context when loading the asset
  62823. * @param name The mesh name when loading the asset
  62824. * @param node The glTF node when loading the asset
  62825. * @param mesh The glTF mesh when loading the asset
  62826. * @param primitive The glTF mesh primitive property
  62827. * @param assign A function called synchronously after parsing the glTF properties
  62828. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  62829. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  62830. private _loadVertexDataAsync;
  62831. private _createMorphTargets;
  62832. private _loadMorphTargetsAsync;
  62833. private _loadMorphTargetVertexDataAsync;
  62834. private static _LoadTransform;
  62835. private _loadSkinAsync;
  62836. private _loadBones;
  62837. private _loadBone;
  62838. private _loadSkinInverseBindMatricesDataAsync;
  62839. private _updateBoneMatrices;
  62840. private _getNodeMatrix;
  62841. /**
  62842. * Loads a glTF camera.
  62843. * @param context The context when loading the asset
  62844. * @param camera The glTF camera property
  62845. * @param assign A function called synchronously after parsing the glTF properties
  62846. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  62847. */
  62848. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  62849. private _loadAnimationsAsync;
  62850. /**
  62851. * Loads a glTF animation.
  62852. * @param context The context when loading the asset
  62853. * @param animation The glTF animation property
  62854. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  62855. */
  62856. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  62857. /**
  62858. * @hidden Loads a glTF animation channel.
  62859. * @param context The context when loading the asset
  62860. * @param animationContext The context of the animation when loading the asset
  62861. * @param animation The glTF animation property
  62862. * @param channel The glTF animation channel property
  62863. * @param babylonAnimationGroup The babylon animation group property
  62864. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  62865. * @returns A void promise when the channel load is complete
  62866. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  62867. private _loadAnimationSamplerAsync;
  62868. private _loadBufferAsync;
  62869. /**
  62870. * Loads a glTF buffer view.
  62871. * @param context The context when loading the asset
  62872. * @param bufferView The glTF buffer view property
  62873. * @returns A promise that resolves with the loaded data when the load is complete
  62874. */
  62875. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  62876. private _loadIndicesAccessorAsync;
  62877. private _loadFloatAccessorAsync;
  62878. private _loadVertexBufferViewAsync;
  62879. private _loadVertexAccessorAsync;
  62880. private _loadMaterialMetallicRoughnessPropertiesAsync;
  62881. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  62882. private _createDefaultMaterial;
  62883. /**
  62884. * Creates a Babylon material from a glTF material.
  62885. * @param context The context when loading the asset
  62886. * @param material The glTF material property
  62887. * @param babylonDrawMode The draw mode for the Babylon material
  62888. * @returns The Babylon material
  62889. */
  62890. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  62891. /**
  62892. * Loads properties from a glTF material into a Babylon material.
  62893. * @param context The context when loading the asset
  62894. * @param material The glTF material property
  62895. * @param babylonMaterial The Babylon material
  62896. * @returns A promise that resolves when the load is complete
  62897. */
  62898. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  62899. /**
  62900. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  62901. * @param context The context when loading the asset
  62902. * @param material The glTF material property
  62903. * @param babylonMaterial The Babylon material
  62904. * @returns A promise that resolves when the load is complete
  62905. */
  62906. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  62907. /**
  62908. * Loads the alpha properties from a glTF material into a Babylon material.
  62909. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  62910. * @param context The context when loading the asset
  62911. * @param material The glTF material property
  62912. * @param babylonMaterial The Babylon material
  62913. */
  62914. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  62915. /**
  62916. * Loads a glTF texture info.
  62917. * @param context The context when loading the asset
  62918. * @param textureInfo The glTF texture info property
  62919. * @param assign A function called synchronously after parsing the glTF properties
  62920. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  62921. */
  62922. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  62923. private _loadTextureAsync;
  62924. private _loadSampler;
  62925. /**
  62926. * Loads a glTF image.
  62927. * @param context The context when loading the asset
  62928. * @param image The glTF image property
  62929. * @returns A promise that resolves with the loaded data when the load is complete
  62930. */
  62931. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  62932. /**
  62933. * Loads a glTF uri.
  62934. * @param context The context when loading the asset
  62935. * @param property The glTF property associated with the uri
  62936. * @param uri The base64 or relative uri
  62937. * @returns A promise that resolves with the loaded data when the load is complete
  62938. */
  62939. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  62940. private _onProgress;
  62941. /**
  62942. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  62943. * @param babylonObject the Babylon object with metadata
  62944. * @param pointer the JSON pointer
  62945. */
  62946. static AddPointerMetadata(babylonObject: {
  62947. metadata: any;
  62948. }, pointer: string): void;
  62949. private static _GetTextureWrapMode;
  62950. private static _GetTextureSamplingMode;
  62951. private static _GetTypedArray;
  62952. private static _GetNumComponents;
  62953. private static _ValidateUri;
  62954. private static _GetDrawMode;
  62955. private _compileMaterialsAsync;
  62956. private _compileShadowGeneratorsAsync;
  62957. private _forEachExtensions;
  62958. private _applyExtensions;
  62959. private _extensionsOnLoading;
  62960. private _extensionsOnReady;
  62961. private _extensionsLoadSceneAsync;
  62962. private _extensionsLoadNodeAsync;
  62963. private _extensionsLoadCameraAsync;
  62964. private _extensionsLoadVertexDataAsync;
  62965. private _extensionsLoadMeshPrimitiveAsync;
  62966. private _extensionsLoadMaterialAsync;
  62967. private _extensionsCreateMaterial;
  62968. private _extensionsLoadMaterialPropertiesAsync;
  62969. private _extensionsLoadTextureInfoAsync;
  62970. private _extensionsLoadAnimationAsync;
  62971. private _extensionsLoadSkinAsync;
  62972. private _extensionsLoadUriAsync;
  62973. /**
  62974. * Helper method called by a loader extension to load an glTF extension.
  62975. * @param context The context when loading the asset
  62976. * @param property The glTF property to load the extension from
  62977. * @param extensionName The name of the extension to load
  62978. * @param actionAsync The action to run
  62979. * @returns The promise returned by actionAsync or null if the extension does not exist
  62980. */
  62981. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  62982. /**
  62983. * Helper method called by a loader extension to load a glTF extra.
  62984. * @param context The context when loading the asset
  62985. * @param property The glTF property to load the extra from
  62986. * @param extensionName The name of the extension to load
  62987. * @param actionAsync The action to run
  62988. * @returns The promise returned by actionAsync or null if the extra does not exist
  62989. */
  62990. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  62991. /**
  62992. * Increments the indentation level and logs a message.
  62993. * @param message The message to log
  62994. */
  62995. logOpen(message: string): void;
  62996. /**
  62997. * Decrements the indentation level.
  62998. */
  62999. logClose(): void;
  63000. /**
  63001. * Logs a message
  63002. * @param message The message to log
  63003. */
  63004. log(message: string): void;
  63005. /**
  63006. * Starts a performance counter.
  63007. * @param counterName The name of the performance counter
  63008. */
  63009. startPerformanceCounter(counterName: string): void;
  63010. /**
  63011. * Ends a performance counter.
  63012. * @param counterName The name of the performance counter
  63013. */
  63014. endPerformanceCounter(counterName: string): void;
  63015. }
  63016. }
  63017. declare module BABYLON.GLTF2.Loader.Extensions {
  63018. /**
  63019. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  63020. */
  63021. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  63022. /** The name of this extension. */
  63023. readonly name: string;
  63024. /** Defines whether this extension is enabled. */
  63025. enabled: boolean;
  63026. private _loader;
  63027. private _lights?;
  63028. /** @hidden */
  63029. constructor(loader: GLTFLoader);
  63030. /** @hidden */
  63031. dispose(): void;
  63032. /** @hidden */
  63033. onLoading(): void;
  63034. /** @hidden */
  63035. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  63036. private _loadLightAsync;
  63037. }
  63038. }
  63039. declare module BABYLON.GLTF2.Loader.Extensions {
  63040. /**
  63041. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  63042. */
  63043. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  63044. /** The name of this extension. */
  63045. readonly name: string;
  63046. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  63047. dracoCompression?: DracoCompression;
  63048. /** Defines whether this extension is enabled. */
  63049. enabled: boolean;
  63050. private _loader;
  63051. /** @hidden */
  63052. constructor(loader: GLTFLoader);
  63053. /** @hidden */
  63054. dispose(): void;
  63055. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63056. }
  63057. }
  63058. declare module BABYLON.GLTF2.Loader.Extensions {
  63059. /**
  63060. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  63061. */
  63062. export class KHR_lights implements IGLTFLoaderExtension {
  63063. /** The name of this extension. */
  63064. readonly name: string;
  63065. /** Defines whether this extension is enabled. */
  63066. enabled: boolean;
  63067. private _loader;
  63068. private _lights?;
  63069. /** @hidden */
  63070. constructor(loader: GLTFLoader);
  63071. /** @hidden */
  63072. dispose(): void;
  63073. /** @hidden */
  63074. onLoading(): void;
  63075. /** @hidden */
  63076. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63077. }
  63078. }
  63079. declare module BABYLON.GLTF2.Loader.Extensions {
  63080. /**
  63081. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  63082. */
  63083. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  63084. /** The name of this extension. */
  63085. readonly name: string;
  63086. /** Defines whether this extension is enabled. */
  63087. enabled: boolean;
  63088. private _loader;
  63089. /** @hidden */
  63090. constructor(loader: GLTFLoader);
  63091. /** @hidden */
  63092. dispose(): void;
  63093. /** @hidden */
  63094. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63095. private _loadSpecularGlossinessPropertiesAsync;
  63096. }
  63097. }
  63098. declare module BABYLON.GLTF2.Loader.Extensions {
  63099. /**
  63100. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  63101. */
  63102. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  63103. /** The name of this extension. */
  63104. readonly name: string;
  63105. /** Defines whether this extension is enabled. */
  63106. enabled: boolean;
  63107. private _loader;
  63108. /** @hidden */
  63109. constructor(loader: GLTFLoader);
  63110. /** @hidden */
  63111. dispose(): void;
  63112. /** @hidden */
  63113. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63114. private _loadUnlitPropertiesAsync;
  63115. }
  63116. }
  63117. declare module BABYLON.GLTF2.Loader.Extensions {
  63118. /**
  63119. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  63120. */
  63121. export class KHR_texture_transform implements IGLTFLoaderExtension {
  63122. /** The name of this extension. */
  63123. readonly name: string;
  63124. /** Defines whether this extension is enabled. */
  63125. enabled: boolean;
  63126. private _loader;
  63127. /** @hidden */
  63128. constructor(loader: GLTFLoader);
  63129. /** @hidden */
  63130. dispose(): void;
  63131. /** @hidden */
  63132. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63133. }
  63134. }
  63135. declare module BABYLON.GLTF2.Loader.Extensions {
  63136. /**
  63137. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  63138. */
  63139. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  63140. /** The name of this extension. */
  63141. readonly name: string;
  63142. /** Defines whether this extension is enabled. */
  63143. enabled: boolean;
  63144. private _loader;
  63145. private _clips;
  63146. private _emitters;
  63147. /** @hidden */
  63148. constructor(loader: GLTFLoader);
  63149. /** @hidden */
  63150. dispose(): void;
  63151. /** @hidden */
  63152. onLoading(): void;
  63153. /** @hidden */
  63154. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  63155. /** @hidden */
  63156. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63157. /** @hidden */
  63158. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63159. private _loadClipAsync;
  63160. private _loadEmitterAsync;
  63161. private _getEventAction;
  63162. private _loadAnimationEventAsync;
  63163. }
  63164. }
  63165. declare module BABYLON.GLTF2.Loader.Extensions {
  63166. /**
  63167. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  63168. */
  63169. export class MSFT_lod implements IGLTFLoaderExtension {
  63170. /** The name of this extension. */
  63171. readonly name: string;
  63172. /** Defines whether this extension is enabled. */
  63173. enabled: boolean;
  63174. /**
  63175. * Maximum number of LODs to load, starting from the lowest LOD.
  63176. */
  63177. maxLODsToLoad: number;
  63178. /**
  63179. * Observable raised when all node LODs of one level are loaded.
  63180. * The event data is the index of the loaded LOD starting from zero.
  63181. * Dispose the loader to cancel the loading of the next level of LODs.
  63182. */
  63183. onNodeLODsLoadedObservable: Observable<number>;
  63184. /**
  63185. * Observable raised when all material LODs of one level are loaded.
  63186. * The event data is the index of the loaded LOD starting from zero.
  63187. * Dispose the loader to cancel the loading of the next level of LODs.
  63188. */
  63189. onMaterialLODsLoadedObservable: Observable<number>;
  63190. private _loader;
  63191. private _nodeIndexLOD;
  63192. private _nodeSignalLODs;
  63193. private _nodePromiseLODs;
  63194. private _materialIndexLOD;
  63195. private _materialSignalLODs;
  63196. private _materialPromiseLODs;
  63197. /** @hidden */
  63198. constructor(loader: GLTFLoader);
  63199. /** @hidden */
  63200. dispose(): void;
  63201. /** @hidden */
  63202. onReady(): void;
  63203. /** @hidden */
  63204. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63205. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63206. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63207. /**
  63208. * Gets an array of LOD properties from lowest to highest.
  63209. */
  63210. private _getLODs;
  63211. private _disposeUnusedMaterials;
  63212. }
  63213. }
  63214. declare module BABYLON.GLTF2.Loader.Extensions {
  63215. /** @hidden */
  63216. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  63217. readonly name: string;
  63218. enabled: boolean;
  63219. private _loader;
  63220. constructor(loader: GLTFLoader);
  63221. dispose(): void;
  63222. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63223. }
  63224. }
  63225. declare module BABYLON.GLTF2.Loader.Extensions {
  63226. /** @hidden */
  63227. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  63228. readonly name: string;
  63229. enabled: boolean;
  63230. private _loader;
  63231. constructor(loader: GLTFLoader);
  63232. dispose(): void;
  63233. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63234. }
  63235. }
  63236. declare module BABYLON {
  63237. /**
  63238. * Class reading and parsing the MTL file bundled with the obj file.
  63239. */
  63240. export class MTLFileLoader {
  63241. /**
  63242. * All material loaded from the mtl will be set here
  63243. */
  63244. materials: StandardMaterial[];
  63245. /**
  63246. * This function will read the mtl file and create each material described inside
  63247. * This function could be improve by adding :
  63248. * -some component missing (Ni, Tf...)
  63249. * -including the specific options available
  63250. *
  63251. * @param scene defines the scene the material will be created in
  63252. * @param data defines the mtl data to parse
  63253. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  63254. */
  63255. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  63256. /**
  63257. * Gets the texture for the material.
  63258. *
  63259. * If the material is imported from input file,
  63260. * We sanitize the url to ensure it takes the textre from aside the material.
  63261. *
  63262. * @param rootUrl The root url to load from
  63263. * @param value The value stored in the mtl
  63264. * @return The Texture
  63265. */
  63266. private static _getTexture;
  63267. }
  63268. /**
  63269. * Options for loading OBJ/MTL files
  63270. */
  63271. type MeshLoadOptions = {
  63272. /**
  63273. * Defines if UVs are optimized by default during load.
  63274. */
  63275. OptimizeWithUV: boolean;
  63276. /**
  63277. * Defines custom scaling of UV coordinates of loaded meshes.
  63278. */
  63279. UVScaling: Vector2;
  63280. /**
  63281. * Invert model on y-axis (does a model scaling inversion)
  63282. */
  63283. InvertY: boolean;
  63284. /**
  63285. * Invert Y-Axis of referenced textures on load
  63286. */
  63287. InvertTextureY: boolean;
  63288. /**
  63289. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  63290. */
  63291. ImportVertexColors: boolean;
  63292. /**
  63293. * Compute the normals for the model, even if normals are present in the file.
  63294. */
  63295. ComputeNormals: boolean;
  63296. /**
  63297. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  63298. */
  63299. SkipMaterials: boolean;
  63300. /**
  63301. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  63302. */
  63303. MaterialLoadingFailsSilently: boolean;
  63304. };
  63305. /**
  63306. * OBJ file type loader.
  63307. * This is a babylon scene loader plugin.
  63308. */
  63309. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63310. /**
  63311. * Defines if UVs are optimized by default during load.
  63312. */
  63313. static OPTIMIZE_WITH_UV: boolean;
  63314. /**
  63315. * Invert model on y-axis (does a model scaling inversion)
  63316. */
  63317. static INVERT_Y: boolean;
  63318. /**
  63319. * Invert Y-Axis of referenced textures on load
  63320. */
  63321. static INVERT_TEXTURE_Y: boolean;
  63322. /**
  63323. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  63324. */
  63325. static IMPORT_VERTEX_COLORS: boolean;
  63326. /**
  63327. * Compute the normals for the model, even if normals are present in the file.
  63328. */
  63329. static COMPUTE_NORMALS: boolean;
  63330. /**
  63331. * Defines custom scaling of UV coordinates of loaded meshes.
  63332. */
  63333. static UV_SCALING: Vector2;
  63334. /**
  63335. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  63336. */
  63337. static SKIP_MATERIALS: boolean;
  63338. /**
  63339. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  63340. *
  63341. * Defaults to true for backwards compatibility.
  63342. */
  63343. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  63344. /**
  63345. * Defines the name of the plugin.
  63346. */
  63347. name: string;
  63348. /**
  63349. * Defines the extension the plugin is able to load.
  63350. */
  63351. extensions: string;
  63352. /** @hidden */
  63353. obj: RegExp;
  63354. /** @hidden */
  63355. group: RegExp;
  63356. /** @hidden */
  63357. mtllib: RegExp;
  63358. /** @hidden */
  63359. usemtl: RegExp;
  63360. /** @hidden */
  63361. smooth: RegExp;
  63362. /** @hidden */
  63363. vertexPattern: RegExp;
  63364. /** @hidden */
  63365. normalPattern: RegExp;
  63366. /** @hidden */
  63367. uvPattern: RegExp;
  63368. /** @hidden */
  63369. facePattern1: RegExp;
  63370. /** @hidden */
  63371. facePattern2: RegExp;
  63372. /** @hidden */
  63373. facePattern3: RegExp;
  63374. /** @hidden */
  63375. facePattern4: RegExp;
  63376. /** @hidden */
  63377. facePattern5: RegExp;
  63378. private _meshLoadOptions;
  63379. /**
  63380. * Creates loader for .OBJ files
  63381. *
  63382. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  63383. */
  63384. constructor(meshLoadOptions?: MeshLoadOptions);
  63385. private static readonly currentMeshLoadOptions;
  63386. /**
  63387. * Calls synchronously the MTL file attached to this obj.
  63388. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  63389. * Without this function materials are not displayed in the first frame (but displayed after).
  63390. * In consequence it is impossible to get material information in your HTML file
  63391. *
  63392. * @param url The URL of the MTL file
  63393. * @param rootUrl
  63394. * @param onSuccess Callback function to be called when the MTL file is loaded
  63395. * @private
  63396. */
  63397. private _loadMTL;
  63398. /**
  63399. * Instantiates a OBJ file loader plugin.
  63400. * @returns the created plugin
  63401. */
  63402. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  63403. /**
  63404. * If the data string can be loaded directly.
  63405. *
  63406. * @param data string containing the file data
  63407. * @returns if the data can be loaded directly
  63408. */
  63409. canDirectLoad(data: string): boolean;
  63410. /**
  63411. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  63412. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63413. * @param scene the scene the meshes should be added to
  63414. * @param data the OBJ data to load
  63415. * @param rootUrl root url to load from
  63416. * @param onProgress event that fires when loading progress has occured
  63417. * @param fileName Defines the name of the file to load
  63418. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63419. */
  63420. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63421. meshes: AbstractMesh[];
  63422. particleSystems: IParticleSystem[];
  63423. skeletons: Skeleton[];
  63424. animationGroups: AnimationGroup[];
  63425. }>;
  63426. /**
  63427. * Imports all objects from the loaded OBJ data and adds them to the scene
  63428. * @param scene the scene the objects should be added to
  63429. * @param data the OBJ data to load
  63430. * @param rootUrl root url to load from
  63431. * @param onProgress event that fires when loading progress has occured
  63432. * @param fileName Defines the name of the file to load
  63433. * @returns a promise which completes when objects have been loaded to the scene
  63434. */
  63435. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63436. /**
  63437. * Load into an asset container.
  63438. * @param scene The scene to load into
  63439. * @param data The data to import
  63440. * @param rootUrl The root url for scene and resources
  63441. * @param onProgress The callback when the load progresses
  63442. * @param fileName Defines the name of the file to load
  63443. * @returns The loaded asset container
  63444. */
  63445. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63446. /**
  63447. * Read the OBJ file and create an Array of meshes.
  63448. * Each mesh contains all information given by the OBJ and the MTL file.
  63449. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  63450. *
  63451. * @param meshesNames
  63452. * @param scene Scene The scene where are displayed the data
  63453. * @param data String The content of the obj file
  63454. * @param rootUrl String The path to the folder
  63455. * @returns Array<AbstractMesh>
  63456. * @private
  63457. */
  63458. private _parseSolid;
  63459. }
  63460. }
  63461. declare module BABYLON {
  63462. /**
  63463. * STL file type loader.
  63464. * This is a babylon scene loader plugin.
  63465. */
  63466. export class STLFileLoader implements ISceneLoaderPlugin {
  63467. /** @hidden */
  63468. solidPattern: RegExp;
  63469. /** @hidden */
  63470. facetsPattern: RegExp;
  63471. /** @hidden */
  63472. normalPattern: RegExp;
  63473. /** @hidden */
  63474. vertexPattern: RegExp;
  63475. /**
  63476. * Defines the name of the plugin.
  63477. */
  63478. name: string;
  63479. /**
  63480. * Defines the extensions the stl loader is able to load.
  63481. * force data to come in as an ArrayBuffer
  63482. * we'll convert to string if it looks like it's an ASCII .stl
  63483. */
  63484. extensions: ISceneLoaderPluginExtensions;
  63485. /**
  63486. * Import meshes into a scene.
  63487. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  63488. * @param scene The scene to import into
  63489. * @param data The data to import
  63490. * @param rootUrl The root url for scene and resources
  63491. * @param meshes The meshes array to import into
  63492. * @param particleSystems The particle systems array to import into
  63493. * @param skeletons The skeletons array to import into
  63494. * @param onError The callback when import fails
  63495. * @returns True if successful or false otherwise
  63496. */
  63497. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  63498. /**
  63499. * Load into a scene.
  63500. * @param scene The scene to load into
  63501. * @param data The data to import
  63502. * @param rootUrl The root url for scene and resources
  63503. * @param onError The callback when import fails
  63504. * @returns true if successful or false otherwise
  63505. */
  63506. load(scene: Scene, data: any, rootUrl: string): boolean;
  63507. /**
  63508. * Load into an asset container.
  63509. * @param scene The scene to load into
  63510. * @param data The data to import
  63511. * @param rootUrl The root url for scene and resources
  63512. * @param onError The callback when import fails
  63513. * @returns The loaded asset container
  63514. */
  63515. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  63516. private _isBinary;
  63517. private _parseBinary;
  63518. private _parseASCII;
  63519. }
  63520. }
  63521. declare module BABYLON {
  63522. /**
  63523. * Class for generating OBJ data from a Babylon scene.
  63524. */
  63525. export class OBJExport {
  63526. /**
  63527. * Exports the geometry of a Mesh array in .OBJ file format (text)
  63528. * @param mesh defines the list of meshes to serialize
  63529. * @param materials defines if materials should be exported
  63530. * @param matlibname defines the name of the associated mtl file
  63531. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  63532. * @returns the OBJ content
  63533. */
  63534. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  63535. /**
  63536. * Exports the material(s) of a mesh in .MTL file format (text)
  63537. * @param mesh defines the mesh to extract the material from
  63538. * @returns the mtl content
  63539. */
  63540. static MTL(mesh: Mesh): string;
  63541. }
  63542. }
  63543. declare module BABYLON {
  63544. /** @hidden */
  63545. export var __IGLTFExporterExtension: number;
  63546. /**
  63547. * Interface for extending the exporter
  63548. * @hidden
  63549. */
  63550. export interface IGLTFExporterExtension {
  63551. /**
  63552. * The name of this extension
  63553. */
  63554. readonly name: string;
  63555. /**
  63556. * Defines whether this extension is enabled
  63557. */
  63558. enabled: boolean;
  63559. /**
  63560. * Defines whether this extension is required
  63561. */
  63562. required: boolean;
  63563. }
  63564. }
  63565. declare module BABYLON.GLTF2.Exporter {
  63566. /** @hidden */
  63567. export var __IGLTFExporterExtensionV2: number;
  63568. /**
  63569. * Interface for a glTF exporter extension
  63570. * @hidden
  63571. */
  63572. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  63573. /**
  63574. * Define this method to modify the default behavior before exporting a texture
  63575. * @param context The context when loading the asset
  63576. * @param babylonTexture The glTF texture info property
  63577. * @param mimeType The mime-type of the generated image
  63578. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  63579. */
  63580. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  63581. /**
  63582. * Define this method to modify the default behavior when exporting texture info
  63583. * @param context The context when loading the asset
  63584. * @param meshPrimitive glTF mesh primitive
  63585. * @param babylonSubMesh Babylon submesh
  63586. * @param binaryWriter glTF serializer binary writer instance
  63587. * @returns nullable IMeshPrimitive promise
  63588. */
  63589. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  63590. /**
  63591. * Define this method to modify the default behavior when exporting a node
  63592. * @param context The context when exporting the node
  63593. * @param node glTF node
  63594. * @param babylonNode BabylonJS node
  63595. * @returns nullable INode promise
  63596. */
  63597. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  63598. /**
  63599. * Called after the exporter state changes to EXPORTING
  63600. */
  63601. onExporting?(): void;
  63602. }
  63603. }
  63604. declare module BABYLON.GLTF2.Exporter {
  63605. /**
  63606. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  63607. * @hidden
  63608. */
  63609. export class _GLTFMaterialExporter {
  63610. /**
  63611. * Represents the dielectric specular values for R, G and B
  63612. */
  63613. private static readonly _DielectricSpecular;
  63614. /**
  63615. * Allows the maximum specular power to be defined for material calculations
  63616. */
  63617. private static readonly _MaxSpecularPower;
  63618. /**
  63619. * Mapping to store textures
  63620. */
  63621. private _textureMap;
  63622. /**
  63623. * Numeric tolerance value
  63624. */
  63625. private static readonly _Epsilon;
  63626. /**
  63627. * Reference to the glTF Exporter
  63628. */
  63629. private _exporter;
  63630. constructor(exporter: _Exporter);
  63631. /**
  63632. * Specifies if two colors are approximately equal in value
  63633. * @param color1 first color to compare to
  63634. * @param color2 second color to compare to
  63635. * @param epsilon threshold value
  63636. */
  63637. private static FuzzyEquals;
  63638. /**
  63639. * Gets the materials from a Babylon scene and converts them to glTF materials
  63640. * @param scene babylonjs scene
  63641. * @param mimeType texture mime type
  63642. * @param images array of images
  63643. * @param textures array of textures
  63644. * @param materials array of materials
  63645. * @param imageData mapping of texture names to base64 textures
  63646. * @param hasTextureCoords specifies if texture coordinates are present on the material
  63647. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63648. /**
  63649. * Makes a copy of the glTF material without the texture parameters
  63650. * @param originalMaterial original glTF material
  63651. * @returns glTF material without texture parameters
  63652. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  63653. /**
  63654. * Specifies if the material has any texture parameters present
  63655. * @param material glTF Material
  63656. * @returns boolean specifying if texture parameters are present
  63657. */ private _hasTexturesPresent(material: IMaterial): boolean;
  63658. /**
  63659. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  63660. * @param babylonStandardMaterial
  63661. * @returns glTF Metallic Roughness Material representation
  63662. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  63663. /**
  63664. * Computes the metallic factor
  63665. * @param diffuse diffused value
  63666. * @param specular specular value
  63667. * @param oneMinusSpecularStrength one minus the specular strength
  63668. * @returns metallic value
  63669. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  63670. /**
  63671. * Gets the glTF alpha mode from the Babylon Material
  63672. * @param babylonMaterial Babylon Material
  63673. * @returns The Babylon alpha mode value
  63674. */ private _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  63675. /**
  63676. * Converts a Babylon Standard Material to a glTF Material
  63677. * @param babylonStandardMaterial BJS Standard Material
  63678. * @param mimeType mime type to use for the textures
  63679. * @param images array of glTF image interfaces
  63680. * @param textures array of glTF texture interfaces
  63681. * @param materials array of glTF material interfaces
  63682. * @param imageData map of image file name to data
  63683. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63684. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63685. /**
  63686. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  63687. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  63688. * @param mimeType mime type to use for the textures
  63689. * @param images array of glTF image interfaces
  63690. * @param textures array of glTF texture interfaces
  63691. * @param materials array of glTF material interfaces
  63692. * @param imageData map of image file name to data
  63693. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63694. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63695. /**
  63696. * Converts an image typed array buffer to a base64 image
  63697. * @param buffer typed array buffer
  63698. * @param width width of the image
  63699. * @param height height of the image
  63700. * @param mimeType mimetype of the image
  63701. * @returns base64 image string
  63702. */
  63703. private _createBase64FromCanvasAsync;
  63704. /**
  63705. * Generates a white texture based on the specified width and height
  63706. * @param width width of the texture in pixels
  63707. * @param height height of the texture in pixels
  63708. * @param scene babylonjs scene
  63709. * @returns white texture
  63710. */
  63711. private _createWhiteTexture;
  63712. /**
  63713. * 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
  63714. * @param texture1 first texture to resize
  63715. * @param texture2 second texture to resize
  63716. * @param scene babylonjs scene
  63717. * @returns resized textures or null
  63718. */
  63719. private _resizeTexturesToSameDimensions;
  63720. /**
  63721. * Converts an array of pixels to a Float32Array
  63722. * Throws an error if the pixel format is not supported
  63723. * @param pixels - array buffer containing pixel values
  63724. * @returns Float32 of pixels
  63725. */
  63726. private _convertPixelArrayToFloat32;
  63727. /**
  63728. * Convert Specular Glossiness Textures to Metallic Roughness
  63729. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  63730. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  63731. * @param diffuseTexture texture used to store diffuse information
  63732. * @param specularGlossinessTexture texture used to store specular and glossiness information
  63733. * @param factors specular glossiness material factors
  63734. * @param mimeType the mime type to use for the texture
  63735. * @returns pbr metallic roughness interface or null
  63736. */
  63737. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  63738. /**
  63739. * Converts specular glossiness material properties to metallic roughness
  63740. * @param specularGlossiness interface with specular glossiness material properties
  63741. * @returns interface with metallic roughness material properties
  63742. */
  63743. private _convertSpecularGlossinessToMetallicRoughness;
  63744. /**
  63745. * Calculates the surface reflectance, independent of lighting conditions
  63746. * @param color Color source to calculate brightness from
  63747. * @returns number representing the perceived brightness, or zero if color is undefined
  63748. */
  63749. private _getPerceivedBrightness;
  63750. /**
  63751. * Returns the maximum color component value
  63752. * @param color
  63753. * @returns maximum color component value, or zero if color is null or undefined
  63754. */
  63755. private _getMaxComponent;
  63756. /**
  63757. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  63758. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  63759. * @param mimeType mime type to use for the textures
  63760. * @param images array of glTF image interfaces
  63761. * @param textures array of glTF texture interfaces
  63762. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  63763. * @param imageData map of image file name to data
  63764. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63765. * @returns glTF PBR Metallic Roughness factors
  63766. */
  63767. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  63768. private _getGLTFTextureSampler;
  63769. private _getGLTFTextureWrapMode;
  63770. private _getGLTFTextureWrapModesSampler;
  63771. /**
  63772. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  63773. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  63774. * @param mimeType mime type to use for the textures
  63775. * @param images array of glTF image interfaces
  63776. * @param textures array of glTF texture interfaces
  63777. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  63778. * @param imageData map of image file name to data
  63779. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63780. * @returns glTF PBR Metallic Roughness factors
  63781. */
  63782. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  63783. /**
  63784. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  63785. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  63786. * @param mimeType mime type to use for the textures
  63787. * @param images array of glTF image interfaces
  63788. * @param textures array of glTF texture interfaces
  63789. * @param materials array of glTF material interfaces
  63790. * @param imageData map of image file name to data
  63791. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63792. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63793. private setMetallicRoughnessPbrMaterial;
  63794. private getPixelsFromTexture;
  63795. /**
  63796. * Extracts a texture from a Babylon texture into file data and glTF data
  63797. * @param babylonTexture Babylon texture to extract
  63798. * @param mimeType Mime Type of the babylonTexture
  63799. * @return glTF texture info, or null if the texture format is not supported
  63800. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  63801. /**
  63802. * Builds a texture from base64 string
  63803. * @param base64Texture base64 texture string
  63804. * @param baseTextureName Name to use for the texture
  63805. * @param mimeType image mime type for the texture
  63806. * @param images array of images
  63807. * @param textures array of textures
  63808. * @param imageData map of image data
  63809. * @returns glTF texture info, or null if the texture format is not supported
  63810. */
  63811. private _getTextureInfoFromBase64;
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /**
  63816. * Class for holding and downloading glTF file data
  63817. */
  63818. export class GLTFData {
  63819. /**
  63820. * Object which contains the file name as the key and its data as the value
  63821. */
  63822. glTFFiles: {
  63823. [fileName: string]: string | Blob;
  63824. };
  63825. /**
  63826. * Initializes the glTF file object
  63827. */
  63828. constructor();
  63829. /**
  63830. * Downloads the glTF data as files based on their names and data
  63831. */
  63832. downloadFiles(): void;
  63833. }
  63834. }
  63835. declare module BABYLON {
  63836. /**
  63837. * Holds a collection of exporter options and parameters
  63838. */
  63839. export interface IExportOptions {
  63840. /**
  63841. * Function which indicates whether a babylon node should be exported or not
  63842. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  63843. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  63844. */
  63845. shouldExportNode?(node: Node): boolean;
  63846. /**
  63847. * The sample rate to bake animation curves
  63848. */
  63849. animationSampleRate?: number;
  63850. /**
  63851. * Begin serialization without waiting for the scene to be ready
  63852. */
  63853. exportWithoutWaitingForScene?: boolean;
  63854. }
  63855. /**
  63856. * Class for generating glTF data from a Babylon scene.
  63857. */
  63858. export class GLTF2Export {
  63859. /**
  63860. * Exports the geometry of the scene to .gltf file format asynchronously
  63861. * @param scene Babylon scene with scene hierarchy information
  63862. * @param filePrefix File prefix to use when generating the glTF file
  63863. * @param options Exporter options
  63864. * @returns Returns an object with a .gltf file and associates texture names
  63865. * as keys and their data and paths as values
  63866. */
  63867. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  63868. private static _PreExportAsync;
  63869. private static _PostExportAsync;
  63870. /**
  63871. * Exports the geometry of the scene to .glb file format asychronously
  63872. * @param scene Babylon scene with scene hierarchy information
  63873. * @param filePrefix File prefix to use when generating glb file
  63874. * @param options Exporter options
  63875. * @returns Returns an object with a .glb filename as key and data as value
  63876. */
  63877. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  63878. }
  63879. }
  63880. declare module BABYLON.GLTF2.Exporter {
  63881. /**
  63882. * @hidden
  63883. */
  63884. export class _GLTFUtilities {
  63885. /**
  63886. * Creates a buffer view based on the supplied arguments
  63887. * @param bufferIndex index value of the specified buffer
  63888. * @param byteOffset byte offset value
  63889. * @param byteLength byte length of the bufferView
  63890. * @param byteStride byte distance between conequential elements
  63891. * @param name name of the buffer view
  63892. * @returns bufferView for glTF
  63893. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  63894. /**
  63895. * Creates an accessor based on the supplied arguments
  63896. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  63897. * @param name The name of the accessor
  63898. * @param type The type of the accessor
  63899. * @param componentType The datatype of components in the attribute
  63900. * @param count The number of attributes referenced by this accessor
  63901. * @param byteOffset The offset relative to the start of the bufferView in bytes
  63902. * @param min Minimum value of each component in this attribute
  63903. * @param max Maximum value of each component in this attribute
  63904. * @returns accessor for glTF
  63905. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  63906. /**
  63907. * Calculates the minimum and maximum values of an array of position floats
  63908. * @param positions Positions array of a mesh
  63909. * @param vertexStart Starting vertex offset to calculate min and max values
  63910. * @param vertexCount Number of vertices to check for min and max values
  63911. * @returns min number array and max number array
  63912. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  63913. min: number[];
  63914. max: number[];
  63915. };
  63916. /**
  63917. * Converts a new right-handed Vector3
  63918. * @param vector vector3 array
  63919. * @returns right-handed Vector3
  63920. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  63921. /**
  63922. * Converts a Vector3 to right-handed
  63923. * @param vector Vector3 to convert to right-handed
  63924. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  63925. /**
  63926. * Converts a three element number array to right-handed
  63927. * @param vector number array to convert to right-handed
  63928. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  63929. /**
  63930. * Converts a new right-handed Vector3
  63931. * @param vector vector3 array
  63932. * @returns right-handed Vector3
  63933. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  63934. /**
  63935. * Converts a Vector3 to right-handed
  63936. * @param vector Vector3 to convert to right-handed
  63937. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  63938. /**
  63939. * Converts a three element number array to right-handed
  63940. * @param vector number array to convert to right-handed
  63941. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  63942. /**
  63943. * Converts a Vector4 to right-handed
  63944. * @param vector Vector4 to convert to right-handed
  63945. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  63946. /**
  63947. * Converts a Vector4 to right-handed
  63948. * @param vector Vector4 to convert to right-handed
  63949. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  63950. /**
  63951. * Converts a Quaternion to right-handed
  63952. * @param quaternion Source quaternion to convert to right-handed
  63953. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  63954. /**
  63955. * Converts a Quaternion to right-handed
  63956. * @param quaternion Source quaternion to convert to right-handed
  63957. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  63958. }
  63959. }
  63960. declare module BABYLON.GLTF2.Exporter {
  63961. /**
  63962. * Converts Babylon Scene into glTF 2.0.
  63963. * @hidden
  63964. */
  63965. export class _Exporter {
  63966. /**
  63967. * Stores the glTF to export
  63968. */ private _glTF: IGLTF;
  63969. /**
  63970. * Stores all generated buffer views, which represents views into the main glTF buffer data
  63971. */ private _bufferViews: IBufferView[];
  63972. /**
  63973. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  63974. */ private _accessors: IAccessor[];
  63975. /**
  63976. * Stores all the generated nodes, which contains transform and/or mesh information per node
  63977. */
  63978. private _nodes;
  63979. /**
  63980. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  63981. */
  63982. private _scenes;
  63983. /**
  63984. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  63985. */
  63986. private _meshes;
  63987. /**
  63988. * Stores all the generated material information, which represents the appearance of each primitive
  63989. */ private _materials: IMaterial[]; private _materialMap: {
  63990. [materialID: number]: number;
  63991. };
  63992. /**
  63993. * Stores all the generated texture information, which is referenced by glTF materials
  63994. */ private _textures: ITexture[];
  63995. /**
  63996. * Stores all the generated image information, which is referenced by glTF textures
  63997. */ private _images: IImage[];
  63998. /**
  63999. * Stores all the texture samplers
  64000. */ private _samplers: ISampler[];
  64001. /**
  64002. * Stores all the generated animation samplers, which is referenced by glTF animations
  64003. */
  64004. /**
  64005. * Stores the animations for glTF models
  64006. */
  64007. private _animations;
  64008. /**
  64009. * Stores the total amount of bytes stored in the glTF buffer
  64010. */
  64011. private _totalByteLength;
  64012. /**
  64013. * Stores a reference to the Babylon scene containing the source geometry and material information
  64014. */ private _babylonScene: Scene;
  64015. /**
  64016. * Stores a map of the image data, where the key is the file name and the value
  64017. * is the image data
  64018. */ private _imageData: {
  64019. [fileName: string]: {
  64020. data: Uint8Array;
  64021. mimeType: ImageMimeType;
  64022. };
  64023. };
  64024. /**
  64025. * Stores a map of the unique id of a node to its index in the node array
  64026. */
  64027. private _nodeMap;
  64028. /**
  64029. * Specifies if the Babylon scene should be converted to right-handed on export
  64030. */ private _convertToRightHandedSystem: boolean;
  64031. /**
  64032. * Baked animation sample rate
  64033. */
  64034. private _animationSampleRate;
  64035. /**
  64036. * Callback which specifies if a node should be exported or not
  64037. */
  64038. private _shouldExportNode;
  64039. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  64040. private _extensions;
  64041. private static _ExtensionNames;
  64042. private static _ExtensionFactories;
  64043. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64044. private _forEachExtensions;
  64045. private _extensionsOnExporting;
  64046. /**
  64047. * Load glTF serializer extensions
  64048. */
  64049. private _loadExtensions;
  64050. /**
  64051. * Creates a glTF Exporter instance, which can accept optional exporter options
  64052. * @param babylonScene Babylon scene object
  64053. * @param options Options to modify the behavior of the exporter
  64054. */
  64055. constructor(babylonScene: Scene, options?: IExportOptions);
  64056. /**
  64057. * Registers a glTF exporter extension
  64058. * @param name Name of the extension to export
  64059. * @param factory The factory function that creates the exporter extension
  64060. */
  64061. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  64062. /**
  64063. * Un-registers an exporter extension
  64064. * @param name The name fo the exporter extension
  64065. * @returns A boolean indicating whether the extension has been un-registered
  64066. */
  64067. static UnregisterExtension(name: string): boolean;
  64068. /**
  64069. * Lazy load a local engine with premultiplied alpha set to false
  64070. */ private _getLocalEngine(): Engine;
  64071. private reorderIndicesBasedOnPrimitiveMode;
  64072. /**
  64073. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  64074. * clock-wise during export to glTF
  64075. * @param submesh BabylonJS submesh
  64076. * @param primitiveMode Primitive mode of the mesh
  64077. * @param sideOrientation the winding order of the submesh
  64078. * @param vertexBufferKind The type of vertex attribute
  64079. * @param meshAttributeArray The vertex attribute data
  64080. * @param byteOffset The offset to the binary data
  64081. * @param binaryWriter The binary data for the glTF file
  64082. */
  64083. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  64084. /**
  64085. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  64086. * clock-wise during export to glTF
  64087. * @param submesh BabylonJS submesh
  64088. * @param primitiveMode Primitive mode of the mesh
  64089. * @param sideOrientation the winding order of the submesh
  64090. * @param vertexBufferKind The type of vertex attribute
  64091. * @param meshAttributeArray The vertex attribute data
  64092. * @param byteOffset The offset to the binary data
  64093. * @param binaryWriter The binary data for the glTF file
  64094. */
  64095. private reorderTriangleFillMode;
  64096. /**
  64097. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  64098. * clock-wise during export to glTF
  64099. * @param submesh BabylonJS submesh
  64100. * @param primitiveMode Primitive mode of the mesh
  64101. * @param sideOrientation the winding order of the submesh
  64102. * @param vertexBufferKind The type of vertex attribute
  64103. * @param meshAttributeArray The vertex attribute data
  64104. * @param byteOffset The offset to the binary data
  64105. * @param binaryWriter The binary data for the glTF file
  64106. */
  64107. private reorderTriangleStripDrawMode;
  64108. /**
  64109. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  64110. * clock-wise during export to glTF
  64111. * @param submesh BabylonJS submesh
  64112. * @param primitiveMode Primitive mode of the mesh
  64113. * @param sideOrientation the winding order of the submesh
  64114. * @param vertexBufferKind The type of vertex attribute
  64115. * @param meshAttributeArray The vertex attribute data
  64116. * @param byteOffset The offset to the binary data
  64117. * @param binaryWriter The binary data for the glTF file
  64118. */
  64119. private reorderTriangleFanMode;
  64120. /**
  64121. * Writes the vertex attribute data to binary
  64122. * @param vertices The vertices to write to the binary writer
  64123. * @param byteOffset The offset into the binary writer to overwrite binary data
  64124. * @param vertexAttributeKind The vertex attribute type
  64125. * @param meshAttributeArray The vertex attribute data
  64126. * @param binaryWriter The writer containing the binary data
  64127. */
  64128. private writeVertexAttributeData;
  64129. /**
  64130. * Writes mesh attribute data to a data buffer
  64131. * Returns the bytelength of the data
  64132. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  64133. * @param meshAttributeArray Array containing the attribute data
  64134. * @param binaryWriter The buffer to write the binary data to
  64135. * @param indices Used to specify the order of the vertex data
  64136. */
  64137. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  64138. /**
  64139. * Generates glTF json data
  64140. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  64141. * @param glTFPrefix Text to use when prefixing a glTF file
  64142. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  64143. * @returns json data as string
  64144. */
  64145. private generateJSON;
  64146. /**
  64147. * Generates data for .gltf and .bin files based on the glTF prefix string
  64148. * @param glTFPrefix Text to use when prefixing a glTF file
  64149. * @returns GLTFData with glTF file data
  64150. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  64151. /**
  64152. * Creates a binary buffer for glTF
  64153. * @returns array buffer for binary data
  64154. */
  64155. private _generateBinaryAsync;
  64156. /**
  64157. * Pads the number to a multiple of 4
  64158. * @param num number to pad
  64159. * @returns padded number
  64160. */
  64161. private _getPadding;
  64162. /**
  64163. * Generates a glb file from the json and binary data
  64164. * Returns an object with the glb file name as the key and data as the value
  64165. * @param glTFPrefix
  64166. * @returns object with glb filename as key and data as value
  64167. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  64168. /**
  64169. * Sets the TRS for each node
  64170. * @param node glTF Node for storing the transformation data
  64171. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  64172. */
  64173. private setNodeTransformation;
  64174. private getVertexBufferFromMesh;
  64175. /**
  64176. * Creates a bufferview based on the vertices type for the Babylon mesh
  64177. * @param kind Indicates the type of vertices data
  64178. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  64179. * @param binaryWriter The buffer to write the bufferview data to
  64180. */
  64181. private createBufferViewKind;
  64182. /**
  64183. * The primitive mode of the Babylon mesh
  64184. * @param babylonMesh The BabylonJS mesh
  64185. */
  64186. private getMeshPrimitiveMode;
  64187. /**
  64188. * Sets the primitive mode of the glTF mesh primitive
  64189. * @param meshPrimitive glTF mesh primitive
  64190. * @param primitiveMode The primitive mode
  64191. */
  64192. private setPrimitiveMode;
  64193. /**
  64194. * Sets the vertex attribute accessor based of the glTF mesh primitive
  64195. * @param meshPrimitive glTF mesh primitive
  64196. * @param attributeKind vertex attribute
  64197. * @returns boolean specifying if uv coordinates are present
  64198. */
  64199. private setAttributeKind;
  64200. /**
  64201. * Sets data for the primitive attributes of each submesh
  64202. * @param mesh glTF Mesh object to store the primitive attribute information
  64203. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  64204. * @param binaryWriter Buffer to write the attribute data to
  64205. */
  64206. private setPrimitiveAttributesAsync;
  64207. /**
  64208. * Creates a glTF scene based on the array of meshes
  64209. * Returns the the total byte offset
  64210. * @param babylonScene Babylon scene to get the mesh data from
  64211. * @param binaryWriter Buffer to write binary data to
  64212. */
  64213. private createSceneAsync;
  64214. /**
  64215. * Creates a mapping of Node unique id to node index and handles animations
  64216. * @param babylonScene Babylon Scene
  64217. * @param nodes Babylon transform nodes
  64218. * @param shouldExportNode Callback specifying if a transform node should be exported
  64219. * @param binaryWriter Buffer to write binary data to
  64220. * @returns Node mapping of unique id to index
  64221. */
  64222. private createNodeMapAndAnimationsAsync;
  64223. /**
  64224. * Creates a glTF node from a Babylon mesh
  64225. * @param babylonMesh Source Babylon mesh
  64226. * @param binaryWriter Buffer for storing geometry data
  64227. * @returns glTF node
  64228. */
  64229. private createNodeAsync;
  64230. }
  64231. /**
  64232. * @hidden
  64233. *
  64234. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  64235. */
  64236. export class _BinaryWriter {
  64237. /**
  64238. * Array buffer which stores all binary data
  64239. */
  64240. private _arrayBuffer;
  64241. /**
  64242. * View of the array buffer
  64243. */
  64244. private _dataView;
  64245. /**
  64246. * byte offset of data in array buffer
  64247. */
  64248. private _byteOffset;
  64249. /**
  64250. * Initialize binary writer with an initial byte length
  64251. * @param byteLength Initial byte length of the array buffer
  64252. */
  64253. constructor(byteLength: number);
  64254. /**
  64255. * Resize the array buffer to the specified byte length
  64256. * @param byteLength
  64257. */
  64258. private resizeBuffer;
  64259. /**
  64260. * Get an array buffer with the length of the byte offset
  64261. * @returns ArrayBuffer resized to the byte offset
  64262. */
  64263. getArrayBuffer(): ArrayBuffer;
  64264. /**
  64265. * Get the byte offset of the array buffer
  64266. * @returns byte offset
  64267. */
  64268. getByteOffset(): number;
  64269. /**
  64270. * Stores an UInt8 in the array buffer
  64271. * @param entry
  64272. * @param byteOffset If defined, specifies where to set the value as an offset.
  64273. */
  64274. setUInt8(entry: number, byteOffset?: number): void;
  64275. /**
  64276. * Gets an UInt32 in the array buffer
  64277. * @param entry
  64278. * @param byteOffset If defined, specifies where to set the value as an offset.
  64279. */
  64280. getUInt32(byteOffset: number): number;
  64281. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  64282. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  64283. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  64284. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  64285. /**
  64286. * Stores a Float32 in the array buffer
  64287. * @param entry
  64288. */
  64289. setFloat32(entry: number, byteOffset?: number): void;
  64290. /**
  64291. * Stores an UInt32 in the array buffer
  64292. * @param entry
  64293. * @param byteOffset If defined, specifies where to set the value as an offset.
  64294. */
  64295. setUInt32(entry: number, byteOffset?: number): void;
  64296. }
  64297. }
  64298. declare module BABYLON.GLTF2.Exporter {
  64299. /**
  64300. * @hidden
  64301. * Interface to store animation data.
  64302. */
  64303. export interface _IAnimationData {
  64304. /**
  64305. * Keyframe data.
  64306. */
  64307. inputs: number[];
  64308. /**
  64309. * Value data.
  64310. */
  64311. outputs: number[][];
  64312. /**
  64313. * Animation interpolation data.
  64314. */
  64315. samplerInterpolation: AnimationSamplerInterpolation;
  64316. /**
  64317. * Minimum keyframe value.
  64318. */
  64319. inputsMin: number;
  64320. /**
  64321. * Maximum keyframe value.
  64322. */
  64323. inputsMax: number;
  64324. }
  64325. /**
  64326. * @hidden
  64327. */
  64328. export interface _IAnimationInfo {
  64329. /**
  64330. * The target channel for the animation
  64331. */
  64332. animationChannelTargetPath: AnimationChannelTargetPath;
  64333. /**
  64334. * The glTF accessor type for the data.
  64335. */
  64336. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  64337. /**
  64338. * Specifies if quaternions should be used.
  64339. */
  64340. useQuaternion: boolean;
  64341. }
  64342. /**
  64343. * @hidden
  64344. * Utility class for generating glTF animation data from BabylonJS.
  64345. */
  64346. export class _GLTFAnimation {
  64347. /**
  64348. * @ignore
  64349. *
  64350. * Creates glTF channel animation from BabylonJS animation.
  64351. * @param babylonTransformNode - BabylonJS mesh.
  64352. * @param animation - animation.
  64353. * @param animationChannelTargetPath - The target animation channel.
  64354. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  64355. * @param useQuaternion - Specifies if quaternions are used.
  64356. * @returns nullable IAnimationData
  64357. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  64358. private static _DeduceAnimationInfo;
  64359. /**
  64360. * @ignore
  64361. * Create node animations from the transform node animations
  64362. * @param babylonNode
  64363. * @param runtimeGLTFAnimation
  64364. * @param idleGLTFAnimations
  64365. * @param nodeMap
  64366. * @param nodes
  64367. * @param binaryWriter
  64368. * @param bufferViews
  64369. * @param accessors
  64370. * @param convertToRightHandedSystem
  64371. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  64372. [key: number]: number;
  64373. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  64374. /**
  64375. * @ignore
  64376. * Create node animations from the animation groups
  64377. * @param babylonScene
  64378. * @param glTFAnimations
  64379. * @param nodeMap
  64380. * @param nodes
  64381. * @param binaryWriter
  64382. * @param bufferViews
  64383. * @param accessors
  64384. * @param convertToRightHandedSystem
  64385. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  64386. [key: number]: number;
  64387. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  64388. private static AddAnimation;
  64389. /**
  64390. * Create a baked animation
  64391. * @param babylonTransformNode BabylonJS mesh
  64392. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  64393. * @param animationChannelTargetPath animation target channel
  64394. * @param minFrame minimum animation frame
  64395. * @param maxFrame maximum animation frame
  64396. * @param fps frames per second of the animation
  64397. * @param inputs input key frames of the animation
  64398. * @param outputs output key frame data of the animation
  64399. * @param convertToRightHandedSystem converts the values to right-handed
  64400. * @param useQuaternion specifies if quaternions should be used
  64401. */
  64402. private static _CreateBakedAnimation;
  64403. private static _ConvertFactorToVector3OrQuaternion;
  64404. private static _SetInterpolatedValue;
  64405. /**
  64406. * Creates linear animation from the animation key frames
  64407. * @param babylonTransformNode BabylonJS mesh
  64408. * @param animation BabylonJS animation
  64409. * @param animationChannelTargetPath The target animation channel
  64410. * @param frameDelta The difference between the last and first frame of the animation
  64411. * @param inputs Array to store the key frame times
  64412. * @param outputs Array to store the key frame data
  64413. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  64414. * @param useQuaternion Specifies if quaternions are used in the animation
  64415. */
  64416. private static _CreateLinearOrStepAnimation;
  64417. /**
  64418. * Creates cubic spline animation from the animation key frames
  64419. * @param babylonTransformNode BabylonJS mesh
  64420. * @param animation BabylonJS animation
  64421. * @param animationChannelTargetPath The target animation channel
  64422. * @param frameDelta The difference between the last and first frame of the animation
  64423. * @param inputs Array to store the key frame times
  64424. * @param outputs Array to store the key frame data
  64425. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  64426. * @param useQuaternion Specifies if quaternions are used in the animation
  64427. */
  64428. private static _CreateCubicSplineAnimation;
  64429. private static _GetBasePositionRotationOrScale;
  64430. /**
  64431. * Adds a key frame value
  64432. * @param keyFrame
  64433. * @param animation
  64434. * @param outputs
  64435. * @param animationChannelTargetPath
  64436. * @param basePositionRotationOrScale
  64437. * @param convertToRightHandedSystem
  64438. * @param useQuaternion
  64439. */
  64440. private static _AddKeyframeValue;
  64441. /**
  64442. * Determine the interpolation based on the key frames
  64443. * @param keyFrames
  64444. * @param animationChannelTargetPath
  64445. * @param useQuaternion
  64446. */
  64447. private static _DeduceInterpolation;
  64448. /**
  64449. * Adds an input tangent or output tangent to the output data
  64450. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  64451. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  64452. * @param outputs The animation data by keyframe
  64453. * @param animationChannelTargetPath The target animation channel
  64454. * @param interpolation The interpolation type
  64455. * @param keyFrame The key frame with the animation data
  64456. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  64457. * @param useQuaternion Specifies if quaternions are used
  64458. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  64459. */
  64460. private static AddSplineTangent;
  64461. /**
  64462. * Get the minimum and maximum key frames' frame values
  64463. * @param keyFrames animation key frames
  64464. * @returns the minimum and maximum key frame value
  64465. */
  64466. private static calculateMinMaxKeyFrames;
  64467. }
  64468. }
  64469. declare module BABYLON.GLTF2.Exporter {
  64470. /** @hidden */
  64471. export var textureTransformPixelShader: {
  64472. name: string;
  64473. shader: string;
  64474. };
  64475. }
  64476. declare module BABYLON.GLTF2.Exporter.Extensions {
  64477. /**
  64478. * @hidden
  64479. */
  64480. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  64481. /** Name of this extension */
  64482. readonly name: string;
  64483. /** Defines whether this extension is enabled */
  64484. enabled: boolean;
  64485. /** Defines whether this extension is required */
  64486. required: boolean;
  64487. /** Reference to the glTF exporter */
  64488. private _exporter;
  64489. constructor(exporter: _Exporter);
  64490. dispose(): void;
  64491. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64492. /**
  64493. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  64494. * @param babylonTexture
  64495. * @param offset
  64496. * @param rotation
  64497. * @param scale
  64498. * @param scene
  64499. */
  64500. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  64501. }
  64502. }
  64503. declare module BABYLON.GLTF2.Exporter.Extensions {
  64504. /**
  64505. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  64506. */
  64507. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  64508. /** The name of this extension. */
  64509. readonly name: string;
  64510. /** Defines whether this extension is enabled. */
  64511. enabled: boolean;
  64512. /** Defines whether this extension is required */
  64513. required: boolean;
  64514. /** Reference to the glTF exporter */
  64515. private _exporter;
  64516. private _lights;
  64517. /** @hidden */
  64518. constructor(exporter: _Exporter);
  64519. /** @hidden */
  64520. dispose(): void;
  64521. /** @hidden */
  64522. onExporting(): void;
  64523. /**
  64524. * Define this method to modify the default behavior when exporting a node
  64525. * @param context The context when exporting the node
  64526. * @param node glTF node
  64527. * @param babylonNode BabylonJS node
  64528. * @returns nullable INode promise
  64529. */
  64530. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * Class for generating STL data from a Babylon scene.
  64536. */
  64537. export class STLExport {
  64538. /**
  64539. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  64540. * @param meshes list defines the mesh to serialize
  64541. * @param download triggers the automatic download of the file.
  64542. * @param fileName changes the downloads fileName.
  64543. * @param binary changes the STL to a binary type.
  64544. * @param isLittleEndian toggle for binary type exporter.
  64545. * @returns the STL as UTF8 string
  64546. */
  64547. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  64548. }
  64549. }
  64550. /**
  64551. * @ignoreChildren
  64552. * @ignore
  64553. */
  64554. declare module "babylonjs-gltf2interface" {
  64555. export = BABYLON.GLTF2;
  64556. }
  64557. /**
  64558. * Module for glTF 2.0 Interface
  64559. * @ignoreChildren
  64560. * @ignore
  64561. */
  64562. declare module BABYLON.GLTF2 {
  64563. /**
  64564. * The datatype of the components in the attribute
  64565. */
  64566. const enum AccessorComponentType {
  64567. /**
  64568. * Byte
  64569. */
  64570. BYTE = 5120,
  64571. /**
  64572. * Unsigned Byte
  64573. */
  64574. UNSIGNED_BYTE = 5121,
  64575. /**
  64576. * Short
  64577. */
  64578. SHORT = 5122,
  64579. /**
  64580. * Unsigned Short
  64581. */
  64582. UNSIGNED_SHORT = 5123,
  64583. /**
  64584. * Unsigned Int
  64585. */
  64586. UNSIGNED_INT = 5125,
  64587. /**
  64588. * Float
  64589. */
  64590. FLOAT = 5126,
  64591. }
  64592. /**
  64593. * Specifies if the attirbute is a scalar, vector, or matrix
  64594. */
  64595. const enum AccessorType {
  64596. /**
  64597. * Scalar
  64598. */
  64599. SCALAR = "SCALAR",
  64600. /**
  64601. * Vector2
  64602. */
  64603. VEC2 = "VEC2",
  64604. /**
  64605. * Vector3
  64606. */
  64607. VEC3 = "VEC3",
  64608. /**
  64609. * Vector4
  64610. */
  64611. VEC4 = "VEC4",
  64612. /**
  64613. * Matrix2x2
  64614. */
  64615. MAT2 = "MAT2",
  64616. /**
  64617. * Matrix3x3
  64618. */
  64619. MAT3 = "MAT3",
  64620. /**
  64621. * Matrix4x4
  64622. */
  64623. MAT4 = "MAT4",
  64624. }
  64625. /**
  64626. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  64627. */
  64628. const enum AnimationChannelTargetPath {
  64629. /**
  64630. * Translation
  64631. */
  64632. TRANSLATION = "translation",
  64633. /**
  64634. * Rotation
  64635. */
  64636. ROTATION = "rotation",
  64637. /**
  64638. * Scale
  64639. */
  64640. SCALE = "scale",
  64641. /**
  64642. * Weights
  64643. */
  64644. WEIGHTS = "weights",
  64645. }
  64646. /**
  64647. * Interpolation algorithm
  64648. */
  64649. const enum AnimationSamplerInterpolation {
  64650. /**
  64651. * The animated values are linearly interpolated between keyframes
  64652. */
  64653. LINEAR = "LINEAR",
  64654. /**
  64655. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  64656. */
  64657. STEP = "STEP",
  64658. /**
  64659. * The animation's interpolation is computed using a cubic spline with specified tangents
  64660. */
  64661. CUBICSPLINE = "CUBICSPLINE",
  64662. }
  64663. /**
  64664. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  64665. */
  64666. const enum CameraType {
  64667. /**
  64668. * A perspective camera containing properties to create a perspective projection matrix
  64669. */
  64670. PERSPECTIVE = "perspective",
  64671. /**
  64672. * An orthographic camera containing properties to create an orthographic projection matrix
  64673. */
  64674. ORTHOGRAPHIC = "orthographic",
  64675. }
  64676. /**
  64677. * The mime-type of the image
  64678. */
  64679. const enum ImageMimeType {
  64680. /**
  64681. * JPEG Mime-type
  64682. */
  64683. JPEG = "image/jpeg",
  64684. /**
  64685. * PNG Mime-type
  64686. */
  64687. PNG = "image/png",
  64688. }
  64689. /**
  64690. * The alpha rendering mode of the material
  64691. */
  64692. const enum MaterialAlphaMode {
  64693. /**
  64694. * The alpha value is ignored and the rendered output is fully opaque
  64695. */
  64696. OPAQUE = "OPAQUE",
  64697. /**
  64698. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  64699. */
  64700. MASK = "MASK",
  64701. /**
  64702. * 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)
  64703. */
  64704. BLEND = "BLEND",
  64705. }
  64706. /**
  64707. * The type of the primitives to render
  64708. */
  64709. const enum MeshPrimitiveMode {
  64710. /**
  64711. * Points
  64712. */
  64713. POINTS = 0,
  64714. /**
  64715. * Lines
  64716. */
  64717. LINES = 1,
  64718. /**
  64719. * Line Loop
  64720. */
  64721. LINE_LOOP = 2,
  64722. /**
  64723. * Line Strip
  64724. */
  64725. LINE_STRIP = 3,
  64726. /**
  64727. * Triangles
  64728. */
  64729. TRIANGLES = 4,
  64730. /**
  64731. * Triangle Strip
  64732. */
  64733. TRIANGLE_STRIP = 5,
  64734. /**
  64735. * Triangle Fan
  64736. */
  64737. TRIANGLE_FAN = 6,
  64738. }
  64739. /**
  64740. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  64741. */
  64742. const enum TextureMagFilter {
  64743. /**
  64744. * Nearest
  64745. */
  64746. NEAREST = 9728,
  64747. /**
  64748. * Linear
  64749. */
  64750. LINEAR = 9729,
  64751. }
  64752. /**
  64753. * Minification filter. All valid values correspond to WebGL enums
  64754. */
  64755. const enum TextureMinFilter {
  64756. /**
  64757. * Nearest
  64758. */
  64759. NEAREST = 9728,
  64760. /**
  64761. * Linear
  64762. */
  64763. LINEAR = 9729,
  64764. /**
  64765. * Nearest Mip-Map Nearest
  64766. */
  64767. NEAREST_MIPMAP_NEAREST = 9984,
  64768. /**
  64769. * Linear Mipmap Nearest
  64770. */
  64771. LINEAR_MIPMAP_NEAREST = 9985,
  64772. /**
  64773. * Nearest Mipmap Linear
  64774. */
  64775. NEAREST_MIPMAP_LINEAR = 9986,
  64776. /**
  64777. * Linear Mipmap Linear
  64778. */
  64779. LINEAR_MIPMAP_LINEAR = 9987,
  64780. }
  64781. /**
  64782. * S (U) wrapping mode. All valid values correspond to WebGL enums
  64783. */
  64784. const enum TextureWrapMode {
  64785. /**
  64786. * Clamp to Edge
  64787. */
  64788. CLAMP_TO_EDGE = 33071,
  64789. /**
  64790. * Mirrored Repeat
  64791. */
  64792. MIRRORED_REPEAT = 33648,
  64793. /**
  64794. * Repeat
  64795. */
  64796. REPEAT = 10497,
  64797. }
  64798. /**
  64799. * glTF Property
  64800. */
  64801. interface IProperty {
  64802. /**
  64803. * Dictionary object with extension-specific objects
  64804. */
  64805. extensions?: {
  64806. [key: string]: any;
  64807. };
  64808. /**
  64809. * Application-Specific data
  64810. */
  64811. extras?: any;
  64812. }
  64813. /**
  64814. * glTF Child of Root Property
  64815. */
  64816. interface IChildRootProperty extends IProperty {
  64817. /**
  64818. * The user-defined name of this object
  64819. */
  64820. name?: string;
  64821. }
  64822. /**
  64823. * Indices of those attributes that deviate from their initialization value
  64824. */
  64825. interface IAccessorSparseIndices extends IProperty {
  64826. /**
  64827. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  64828. */
  64829. bufferView: number;
  64830. /**
  64831. * The offset relative to the start of the bufferView in bytes. Must be aligned
  64832. */
  64833. byteOffset?: number;
  64834. /**
  64835. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  64836. */
  64837. componentType: AccessorComponentType;
  64838. }
  64839. /**
  64840. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  64841. */
  64842. interface IAccessorSparseValues extends IProperty {
  64843. /**
  64844. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  64845. */
  64846. bufferView: number;
  64847. /**
  64848. * The offset relative to the start of the bufferView in bytes. Must be aligned
  64849. */
  64850. byteOffset?: number;
  64851. }
  64852. /**
  64853. * Sparse storage of attributes that deviate from their initialization value
  64854. */
  64855. interface IAccessorSparse extends IProperty {
  64856. /**
  64857. * The number of attributes encoded in this sparse accessor
  64858. */
  64859. count: number;
  64860. /**
  64861. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  64862. */
  64863. indices: IAccessorSparseIndices;
  64864. /**
  64865. * 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
  64866. */
  64867. values: IAccessorSparseValues;
  64868. }
  64869. /**
  64870. * 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
  64871. */
  64872. interface IAccessor extends IChildRootProperty {
  64873. /**
  64874. * The index of the bufferview
  64875. */
  64876. bufferView?: number;
  64877. /**
  64878. * The offset relative to the start of the bufferView in bytes
  64879. */
  64880. byteOffset?: number;
  64881. /**
  64882. * The datatype of components in the attribute
  64883. */
  64884. componentType: AccessorComponentType;
  64885. /**
  64886. * Specifies whether integer data values should be normalized
  64887. */
  64888. normalized?: boolean;
  64889. /**
  64890. * The number of attributes referenced by this accessor
  64891. */
  64892. count: number;
  64893. /**
  64894. * Specifies if the attribute is a scalar, vector, or matrix
  64895. */
  64896. type: AccessorType;
  64897. /**
  64898. * Maximum value of each component in this attribute
  64899. */
  64900. max?: number[];
  64901. /**
  64902. * Minimum value of each component in this attribute
  64903. */
  64904. min?: number[];
  64905. /**
  64906. * Sparse storage of attributes that deviate from their initialization value
  64907. */
  64908. sparse?: IAccessorSparse;
  64909. }
  64910. /**
  64911. * Targets an animation's sampler at a node's property
  64912. */
  64913. interface IAnimationChannel extends IProperty {
  64914. /**
  64915. * The index of a sampler in this animation used to compute the value for the target
  64916. */
  64917. sampler: number;
  64918. /**
  64919. * The index of the node and TRS property to target
  64920. */
  64921. target: IAnimationChannelTarget;
  64922. }
  64923. /**
  64924. * The index of the node and TRS property that an animation channel targets
  64925. */
  64926. interface IAnimationChannelTarget extends IProperty {
  64927. /**
  64928. * The index of the node to target
  64929. */
  64930. node: number;
  64931. /**
  64932. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  64933. */
  64934. path: AnimationChannelTargetPath;
  64935. }
  64936. /**
  64937. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  64938. */
  64939. interface IAnimationSampler extends IProperty {
  64940. /**
  64941. * The index of an accessor containing keyframe input values, e.g., time
  64942. */
  64943. input: number;
  64944. /**
  64945. * Interpolation algorithm
  64946. */
  64947. interpolation?: AnimationSamplerInterpolation;
  64948. /**
  64949. * The index of an accessor, containing keyframe output values
  64950. */
  64951. output: number;
  64952. }
  64953. /**
  64954. * A keyframe animation
  64955. */
  64956. interface IAnimation extends IChildRootProperty {
  64957. /**
  64958. * An array of channels, each of which targets an animation's sampler at a node's property
  64959. */
  64960. channels: IAnimationChannel[];
  64961. /**
  64962. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  64963. */
  64964. samplers: IAnimationSampler[];
  64965. }
  64966. /**
  64967. * Metadata about the glTF asset
  64968. */
  64969. interface IAsset extends IChildRootProperty {
  64970. /**
  64971. * A copyright message suitable for display to credit the content creator
  64972. */
  64973. copyright?: string;
  64974. /**
  64975. * Tool that generated this glTF model. Useful for debugging
  64976. */
  64977. generator?: string;
  64978. /**
  64979. * The glTF version that this asset targets
  64980. */
  64981. version: string;
  64982. /**
  64983. * The minimum glTF version that this asset targets
  64984. */
  64985. minVersion?: string;
  64986. }
  64987. /**
  64988. * A buffer points to binary geometry, animation, or skins
  64989. */
  64990. interface IBuffer extends IChildRootProperty {
  64991. /**
  64992. * 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
  64993. */
  64994. uri?: string;
  64995. /**
  64996. * The length of the buffer in bytes
  64997. */
  64998. byteLength: number;
  64999. }
  65000. /**
  65001. * A view into a buffer generally representing a subset of the buffer
  65002. */
  65003. interface IBufferView extends IChildRootProperty {
  65004. /**
  65005. * The index of the buffer
  65006. */
  65007. buffer: number;
  65008. /**
  65009. * The offset into the buffer in bytes
  65010. */
  65011. byteOffset?: number;
  65012. /**
  65013. * The lenth of the bufferView in bytes
  65014. */
  65015. byteLength: number;
  65016. /**
  65017. * The stride, in bytes
  65018. */
  65019. byteStride?: number;
  65020. }
  65021. /**
  65022. * An orthographic camera containing properties to create an orthographic projection matrix
  65023. */
  65024. interface ICameraOrthographic extends IProperty {
  65025. /**
  65026. * The floating-point horizontal magnification of the view. Must not be zero
  65027. */
  65028. xmag: number;
  65029. /**
  65030. * The floating-point vertical magnification of the view. Must not be zero
  65031. */
  65032. ymag: number;
  65033. /**
  65034. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  65035. */
  65036. zfar: number;
  65037. /**
  65038. * The floating-point distance to the near clipping plane
  65039. */
  65040. znear: number;
  65041. }
  65042. /**
  65043. * A perspective camera containing properties to create a perspective projection matrix
  65044. */
  65045. interface ICameraPerspective extends IProperty {
  65046. /**
  65047. * The floating-point aspect ratio of the field of view
  65048. */
  65049. aspectRatio?: number;
  65050. /**
  65051. * The floating-point vertical field of view in radians
  65052. */
  65053. yfov: number;
  65054. /**
  65055. * The floating-point distance to the far clipping plane
  65056. */
  65057. zfar?: number;
  65058. /**
  65059. * The floating-point distance to the near clipping plane
  65060. */
  65061. znear: number;
  65062. }
  65063. /**
  65064. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65065. */
  65066. interface ICamera extends IChildRootProperty {
  65067. /**
  65068. * An orthographic camera containing properties to create an orthographic projection matrix
  65069. */
  65070. orthographic?: ICameraOrthographic;
  65071. /**
  65072. * A perspective camera containing properties to create a perspective projection matrix
  65073. */
  65074. perspective?: ICameraPerspective;
  65075. /**
  65076. * Specifies if the camera uses a perspective or orthographic projection
  65077. */
  65078. type: CameraType;
  65079. }
  65080. /**
  65081. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  65082. */
  65083. interface IImage extends IChildRootProperty {
  65084. /**
  65085. * 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
  65086. */
  65087. uri?: string;
  65088. /**
  65089. * The image's MIME type
  65090. */
  65091. mimeType?: ImageMimeType;
  65092. /**
  65093. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  65094. */
  65095. bufferView?: number;
  65096. }
  65097. /**
  65098. * Material Normal Texture Info
  65099. */
  65100. interface IMaterialNormalTextureInfo extends ITextureInfo {
  65101. /**
  65102. * The scalar multiplier applied to each normal vector of the normal texture
  65103. */
  65104. scale?: number;
  65105. }
  65106. /**
  65107. * Material Occlusion Texture Info
  65108. */
  65109. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  65110. /**
  65111. * A scalar multiplier controlling the amount of occlusion applied
  65112. */
  65113. strength?: number;
  65114. }
  65115. /**
  65116. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  65117. */
  65118. interface IMaterialPbrMetallicRoughness {
  65119. /**
  65120. * The material's base color factor
  65121. */
  65122. baseColorFactor?: number[];
  65123. /**
  65124. * The base color texture
  65125. */
  65126. baseColorTexture?: ITextureInfo;
  65127. /**
  65128. * The metalness of the material
  65129. */
  65130. metallicFactor?: number;
  65131. /**
  65132. * The roughness of the material
  65133. */
  65134. roughnessFactor?: number;
  65135. /**
  65136. * The metallic-roughness texture
  65137. */
  65138. metallicRoughnessTexture?: ITextureInfo;
  65139. }
  65140. /**
  65141. * The material appearance of a primitive
  65142. */
  65143. interface IMaterial extends IChildRootProperty {
  65144. /**
  65145. * 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
  65146. */
  65147. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65148. /**
  65149. * The normal map texture
  65150. */
  65151. normalTexture?: IMaterialNormalTextureInfo;
  65152. /**
  65153. * The occlusion map texture
  65154. */
  65155. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65156. /**
  65157. * The emissive map texture
  65158. */
  65159. emissiveTexture?: ITextureInfo;
  65160. /**
  65161. * 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
  65162. */
  65163. emissiveFactor?: number[];
  65164. /**
  65165. * The alpha rendering mode of the material
  65166. */
  65167. alphaMode?: MaterialAlphaMode;
  65168. /**
  65169. * The alpha cutoff value of the material
  65170. */
  65171. alphaCutoff?: number;
  65172. /**
  65173. * Specifies whether the material is double sided
  65174. */
  65175. doubleSided?: boolean;
  65176. }
  65177. /**
  65178. * Geometry to be rendered with the given material
  65179. */
  65180. interface IMeshPrimitive extends IProperty {
  65181. /**
  65182. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  65183. */
  65184. attributes: {
  65185. [name: string]: number;
  65186. };
  65187. /**
  65188. * The index of the accessor that contains the indices
  65189. */
  65190. indices?: number;
  65191. /**
  65192. * The index of the material to apply to this primitive when rendering
  65193. */
  65194. material?: number;
  65195. /**
  65196. * The type of primitives to render. All valid values correspond to WebGL enums
  65197. */
  65198. mode?: MeshPrimitiveMode;
  65199. /**
  65200. * 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
  65201. */
  65202. targets?: {
  65203. [name: string]: number;
  65204. }[];
  65205. }
  65206. /**
  65207. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  65208. */
  65209. interface IMesh extends IChildRootProperty {
  65210. /**
  65211. * An array of primitives, each defining geometry to be rendered with a material
  65212. */
  65213. primitives: IMeshPrimitive[];
  65214. /**
  65215. * Array of weights to be applied to the Morph Targets
  65216. */
  65217. weights?: number[];
  65218. }
  65219. /**
  65220. * A node in the node hierarchy
  65221. */
  65222. interface INode extends IChildRootProperty {
  65223. /**
  65224. * The index of the camera referenced by this node
  65225. */
  65226. camera?: number;
  65227. /**
  65228. * The indices of this node's children
  65229. */
  65230. children?: number[];
  65231. /**
  65232. * The index of the skin referenced by this node
  65233. */
  65234. skin?: number;
  65235. /**
  65236. * A floating-point 4x4 transformation matrix stored in column-major order
  65237. */
  65238. matrix?: number[];
  65239. /**
  65240. * The index of the mesh in this node
  65241. */
  65242. mesh?: number;
  65243. /**
  65244. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  65245. */
  65246. rotation?: number[];
  65247. /**
  65248. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  65249. */
  65250. scale?: number[];
  65251. /**
  65252. * The node's translation along the x, y, and z axes
  65253. */
  65254. translation?: number[];
  65255. /**
  65256. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  65257. */
  65258. weights?: number[];
  65259. }
  65260. /**
  65261. * Texture sampler properties for filtering and wrapping modes
  65262. */
  65263. interface ISampler extends IChildRootProperty {
  65264. /**
  65265. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65266. */
  65267. magFilter?: TextureMagFilter;
  65268. /**
  65269. * Minification filter. All valid values correspond to WebGL enums
  65270. */
  65271. minFilter?: TextureMinFilter;
  65272. /**
  65273. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65274. */
  65275. wrapS?: TextureWrapMode;
  65276. /**
  65277. * T (V) wrapping mode. All valid values correspond to WebGL enums
  65278. */
  65279. wrapT?: TextureWrapMode;
  65280. }
  65281. /**
  65282. * The root nodes of a scene
  65283. */
  65284. interface IScene extends IChildRootProperty {
  65285. /**
  65286. * The indices of each root node
  65287. */
  65288. nodes: number[];
  65289. }
  65290. /**
  65291. * Joints and matrices defining a skin
  65292. */
  65293. interface ISkin extends IChildRootProperty {
  65294. /**
  65295. * 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
  65296. */
  65297. inverseBindMatrices?: number;
  65298. /**
  65299. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  65300. */
  65301. skeleton?: number;
  65302. /**
  65303. * 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)
  65304. */
  65305. joints: number[];
  65306. }
  65307. /**
  65308. * A texture and its sampler
  65309. */
  65310. interface ITexture extends IChildRootProperty {
  65311. /**
  65312. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  65313. */
  65314. sampler?: number;
  65315. /**
  65316. * The index of the image used by this texture
  65317. */
  65318. source: number;
  65319. }
  65320. /**
  65321. * Reference to a texture
  65322. */
  65323. interface ITextureInfo extends IProperty {
  65324. /**
  65325. * The index of the texture
  65326. */
  65327. index: number;
  65328. /**
  65329. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  65330. */
  65331. texCoord?: number;
  65332. }
  65333. /**
  65334. * The root object for a glTF asset
  65335. */
  65336. interface IGLTF extends IProperty {
  65337. /**
  65338. * An array of accessors. An accessor is a typed view into a bufferView
  65339. */
  65340. accessors?: IAccessor[];
  65341. /**
  65342. * An array of keyframe animations
  65343. */
  65344. animations?: IAnimation[];
  65345. /**
  65346. * Metadata about the glTF asset
  65347. */
  65348. asset: IAsset;
  65349. /**
  65350. * An array of buffers. A buffer points to binary geometry, animation, or skins
  65351. */
  65352. buffers?: IBuffer[];
  65353. /**
  65354. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  65355. */
  65356. bufferViews?: IBufferView[];
  65357. /**
  65358. * An array of cameras
  65359. */
  65360. cameras?: ICamera[];
  65361. /**
  65362. * Names of glTF extensions used somewhere in this asset
  65363. */
  65364. extensionsUsed?: string[];
  65365. /**
  65366. * Names of glTF extensions required to properly load this asset
  65367. */
  65368. extensionsRequired?: string[];
  65369. /**
  65370. * An array of images. An image defines data used to create a texture
  65371. */
  65372. images?: IImage[];
  65373. /**
  65374. * An array of materials. A material defines the appearance of a primitive
  65375. */
  65376. materials?: IMaterial[];
  65377. /**
  65378. * An array of meshes. A mesh is a set of primitives to be rendered
  65379. */
  65380. meshes?: IMesh[];
  65381. /**
  65382. * An array of nodes
  65383. */
  65384. nodes?: INode[];
  65385. /**
  65386. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  65387. */
  65388. samplers?: ISampler[];
  65389. /**
  65390. * The index of the default scene
  65391. */
  65392. scene?: number;
  65393. /**
  65394. * An array of scenes
  65395. */
  65396. scenes?: IScene[];
  65397. /**
  65398. * An array of skins. A skin is defined by joints and matrices
  65399. */
  65400. skins?: ISkin[];
  65401. /**
  65402. * An array of textures
  65403. */
  65404. textures?: ITexture[];
  65405. }
  65406. /**
  65407. * The glTF validation results
  65408. */
  65409. interface IGLTFValidationResults {
  65410. info: {
  65411. generator: string;
  65412. hasAnimations: boolean;
  65413. hasDefaultScene: boolean;
  65414. hasMaterials: boolean;
  65415. hasMorphTargets: boolean;
  65416. hasSkins: boolean;
  65417. hasTextures: boolean;
  65418. maxAttributesUsed: number;
  65419. primitivesCount: number
  65420. };
  65421. issues: {
  65422. messages: Array<string>;
  65423. numErrors: number;
  65424. numHints: number;
  65425. numInfos: number;
  65426. numWarnings: number;
  65427. truncated: boolean
  65428. };
  65429. mimeType: string;
  65430. uri: string;
  65431. validatedAt: string;
  65432. validatorVersion: string;
  65433. }
  65434. /**
  65435. * The glTF validation options
  65436. */
  65437. interface IGLTFValidationOptions {
  65438. uri?: string;
  65439. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  65440. validateAccessorData?: boolean;
  65441. maxIssues?: number;
  65442. ignoredIssues?: Array<string>;
  65443. severityOverrides?: Object;
  65444. }
  65445. /**
  65446. * The glTF validator object
  65447. */
  65448. interface IGLTFValidator {
  65449. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  65450. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  65451. }
  65452. }
  65453. declare module BABYLON {
  65454. /** @hidden */
  65455. export var cellPixelShader: {
  65456. name: string;
  65457. shader: string;
  65458. };
  65459. }
  65460. declare module BABYLON {
  65461. /** @hidden */
  65462. export var cellVertexShader: {
  65463. name: string;
  65464. shader: string;
  65465. };
  65466. }
  65467. declare module BABYLON {
  65468. export class CellMaterial extends BABYLON.PushMaterial {
  65469. private _diffuseTexture;
  65470. diffuseTexture: BABYLON.BaseTexture;
  65471. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  65472. computeHighLevel: boolean;
  65473. private _disableLighting;
  65474. disableLighting: boolean;
  65475. private _maxSimultaneousLights;
  65476. maxSimultaneousLights: number;
  65477. private _renderId;
  65478. constructor(name: string, scene: BABYLON.Scene);
  65479. needAlphaBlending(): boolean;
  65480. needAlphaTesting(): boolean;
  65481. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65482. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65483. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65484. getAnimatables(): BABYLON.IAnimatable[];
  65485. getActiveTextures(): BABYLON.BaseTexture[];
  65486. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65487. dispose(forceDisposeEffect?: boolean): void;
  65488. getClassName(): string;
  65489. clone(name: string): CellMaterial;
  65490. serialize(): any;
  65491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  65492. }
  65493. }
  65494. declare module BABYLON {
  65495. export class CustomShaderStructure {
  65496. FragmentStore: string;
  65497. VertexStore: string;
  65498. constructor();
  65499. }
  65500. export class ShaderSpecialParts {
  65501. constructor();
  65502. Fragment_Begin: string;
  65503. Fragment_Definitions: string;
  65504. Fragment_MainBegin: string;
  65505. Fragment_Custom_Diffuse: string;
  65506. Fragment_Before_Lights: string;
  65507. Fragment_Before_Fog: string;
  65508. Fragment_Custom_Alpha: string;
  65509. Fragment_Before_FragColor: string;
  65510. Vertex_Begin: string;
  65511. Vertex_Definitions: string;
  65512. Vertex_MainBegin: string;
  65513. Vertex_Before_PositionUpdated: string;
  65514. Vertex_Before_NormalUpdated: string;
  65515. Vertex_MainEnd: string;
  65516. }
  65517. export class CustomMaterial extends BABYLON.StandardMaterial {
  65518. static ShaderIndexer: number;
  65519. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  65520. FragmentShader: string;
  65521. VertexShader: string;
  65522. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  65523. ReviewUniform(name: string, arr: string[]): string[];
  65524. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  65525. constructor(name: string, scene: BABYLON.Scene);
  65526. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  65527. Fragment_Begin(shaderPart: string): CustomMaterial;
  65528. Fragment_Definitions(shaderPart: string): CustomMaterial;
  65529. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  65530. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  65531. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  65532. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  65533. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  65534. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  65535. Vertex_Begin(shaderPart: string): CustomMaterial;
  65536. Vertex_Definitions(shaderPart: string): CustomMaterial;
  65537. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  65538. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  65539. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  65540. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  65541. }
  65542. }
  65543. declare module BABYLON {
  65544. export class ShaderAlebdoParts {
  65545. constructor();
  65546. Fragment_Begin: string;
  65547. Fragment_Definitions: string;
  65548. Fragment_MainBegin: string;
  65549. Fragment_Custom_Albedo: string;
  65550. Fragment_Before_Lights: string;
  65551. Fragment_Custom_MetallicRoughness: string;
  65552. Fragment_Custom_MicroSurface: string;
  65553. Fragment_Before_Fog: string;
  65554. Fragment_Custom_Alpha: string;
  65555. Fragment_Before_FragColor: string;
  65556. Vertex_Begin: string;
  65557. Vertex_Definitions: string;
  65558. Vertex_MainBegin: string;
  65559. Vertex_Before_PositionUpdated: string;
  65560. Vertex_Before_NormalUpdated: string;
  65561. Vertex_MainEnd: string;
  65562. }
  65563. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  65564. static ShaderIndexer: number;
  65565. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  65566. FragmentShader: string;
  65567. VertexShader: string;
  65568. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  65569. ReviewUniform(name: string, arr: string[]): string[];
  65570. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  65571. constructor(name: string, scene: BABYLON.Scene);
  65572. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  65573. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  65574. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  65575. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  65576. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  65577. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  65578. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  65579. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  65580. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  65581. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  65582. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  65583. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  65584. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  65585. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  65586. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  65587. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  65588. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  65589. }
  65590. }
  65591. declare module BABYLON {
  65592. /** @hidden */
  65593. export var firePixelShader: {
  65594. name: string;
  65595. shader: string;
  65596. };
  65597. }
  65598. declare module BABYLON {
  65599. /** @hidden */
  65600. export var fireVertexShader: {
  65601. name: string;
  65602. shader: string;
  65603. };
  65604. }
  65605. declare module BABYLON {
  65606. export class FireMaterial extends BABYLON.PushMaterial {
  65607. private _diffuseTexture;
  65608. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65609. private _distortionTexture;
  65610. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65611. private _opacityTexture;
  65612. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65613. diffuseColor: BABYLON.Color3;
  65614. speed: number;
  65615. private _scaledDiffuse;
  65616. private _renderId;
  65617. private _lastTime;
  65618. constructor(name: string, scene: BABYLON.Scene);
  65619. needAlphaBlending(): boolean;
  65620. needAlphaTesting(): boolean;
  65621. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65622. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65623. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65624. getAnimatables(): BABYLON.IAnimatable[];
  65625. getActiveTextures(): BABYLON.BaseTexture[];
  65626. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65627. getClassName(): string;
  65628. dispose(forceDisposeEffect?: boolean): void;
  65629. clone(name: string): FireMaterial;
  65630. serialize(): any;
  65631. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  65632. }
  65633. }
  65634. declare module BABYLON {
  65635. /** @hidden */
  65636. export var furPixelShader: {
  65637. name: string;
  65638. shader: string;
  65639. };
  65640. }
  65641. declare module BABYLON {
  65642. /** @hidden */
  65643. export var furVertexShader: {
  65644. name: string;
  65645. shader: string;
  65646. };
  65647. }
  65648. declare module BABYLON {
  65649. export class FurMaterial extends BABYLON.PushMaterial {
  65650. private _diffuseTexture;
  65651. diffuseTexture: BABYLON.BaseTexture;
  65652. private _heightTexture;
  65653. heightTexture: BABYLON.BaseTexture;
  65654. diffuseColor: BABYLON.Color3;
  65655. furLength: number;
  65656. furAngle: number;
  65657. furColor: BABYLON.Color3;
  65658. furOffset: number;
  65659. furSpacing: number;
  65660. furGravity: BABYLON.Vector3;
  65661. furSpeed: number;
  65662. furDensity: number;
  65663. furOcclusion: number;
  65664. furTexture: BABYLON.DynamicTexture;
  65665. private _disableLighting;
  65666. disableLighting: boolean;
  65667. private _maxSimultaneousLights;
  65668. maxSimultaneousLights: number;
  65669. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  65670. private _renderId;
  65671. private _furTime;
  65672. constructor(name: string, scene: BABYLON.Scene);
  65673. furTime: number;
  65674. needAlphaBlending(): boolean;
  65675. needAlphaTesting(): boolean;
  65676. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65677. updateFur(): void;
  65678. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65679. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65680. getAnimatables(): BABYLON.IAnimatable[];
  65681. getActiveTextures(): BABYLON.BaseTexture[];
  65682. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65683. dispose(forceDisposeEffect?: boolean): void;
  65684. clone(name: string): FurMaterial;
  65685. serialize(): any;
  65686. getClassName(): string;
  65687. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  65688. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  65689. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  65690. }
  65691. }
  65692. declare module BABYLON {
  65693. /** @hidden */
  65694. export var gradientPixelShader: {
  65695. name: string;
  65696. shader: string;
  65697. };
  65698. }
  65699. declare module BABYLON {
  65700. /** @hidden */
  65701. export var gradientVertexShader: {
  65702. name: string;
  65703. shader: string;
  65704. };
  65705. }
  65706. declare module BABYLON {
  65707. export class GradientMaterial extends BABYLON.PushMaterial {
  65708. private _maxSimultaneousLights;
  65709. maxSimultaneousLights: number;
  65710. topColor: BABYLON.Color3;
  65711. topColorAlpha: number;
  65712. bottomColor: BABYLON.Color3;
  65713. bottomColorAlpha: number;
  65714. offset: number;
  65715. scale: number;
  65716. smoothness: number;
  65717. private _disableLighting;
  65718. disableLighting: boolean;
  65719. private _renderId;
  65720. constructor(name: string, scene: BABYLON.Scene);
  65721. needAlphaBlending(): boolean;
  65722. needAlphaTesting(): boolean;
  65723. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65724. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65725. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65726. getAnimatables(): BABYLON.IAnimatable[];
  65727. dispose(forceDisposeEffect?: boolean): void;
  65728. clone(name: string): GradientMaterial;
  65729. serialize(): any;
  65730. getClassName(): string;
  65731. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  65732. }
  65733. }
  65734. declare module BABYLON {
  65735. /** @hidden */
  65736. export var gridPixelShader: {
  65737. name: string;
  65738. shader: string;
  65739. };
  65740. }
  65741. declare module BABYLON {
  65742. /** @hidden */
  65743. export var gridVertexShader: {
  65744. name: string;
  65745. shader: string;
  65746. };
  65747. }
  65748. declare module BABYLON {
  65749. /**
  65750. * The grid materials allows you to wrap any shape with a grid.
  65751. * Colors are customizable.
  65752. */
  65753. export class GridMaterial extends BABYLON.PushMaterial {
  65754. /**
  65755. * Main color of the grid (e.g. between lines)
  65756. */
  65757. mainColor: BABYLON.Color3;
  65758. /**
  65759. * Color of the grid lines.
  65760. */
  65761. lineColor: BABYLON.Color3;
  65762. /**
  65763. * The scale of the grid compared to unit.
  65764. */
  65765. gridRatio: number;
  65766. /**
  65767. * Allows setting an offset for the grid lines.
  65768. */
  65769. gridOffset: BABYLON.Vector3;
  65770. /**
  65771. * The frequency of thicker lines.
  65772. */
  65773. majorUnitFrequency: number;
  65774. /**
  65775. * The visibility of minor units in the grid.
  65776. */
  65777. minorUnitVisibility: number;
  65778. /**
  65779. * The grid opacity outside of the lines.
  65780. */
  65781. opacity: number;
  65782. /**
  65783. * Determine RBG output is premultiplied by alpha value.
  65784. */
  65785. preMultiplyAlpha: boolean;
  65786. private _opacityTexture;
  65787. opacityTexture: BABYLON.BaseTexture;
  65788. private _gridControl;
  65789. private _renderId;
  65790. /**
  65791. * constructor
  65792. * @param name The name given to the material in order to identify it afterwards.
  65793. * @param scene The scene the material is used in.
  65794. */
  65795. constructor(name: string, scene: BABYLON.Scene);
  65796. /**
  65797. * Returns wehter or not the grid requires alpha blending.
  65798. */
  65799. needAlphaBlending(): boolean;
  65800. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  65801. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65802. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65803. /**
  65804. * Dispose the material and its associated resources.
  65805. * @param forceDisposeEffect will also dispose the used effect when true
  65806. */
  65807. dispose(forceDisposeEffect?: boolean): void;
  65808. clone(name: string): GridMaterial;
  65809. serialize(): any;
  65810. getClassName(): string;
  65811. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  65812. }
  65813. }
  65814. declare module BABYLON {
  65815. /** @hidden */
  65816. export var lavaPixelShader: {
  65817. name: string;
  65818. shader: string;
  65819. };
  65820. }
  65821. declare module BABYLON {
  65822. /** @hidden */
  65823. export var lavaVertexShader: {
  65824. name: string;
  65825. shader: string;
  65826. };
  65827. }
  65828. declare module BABYLON {
  65829. export class LavaMaterial extends BABYLON.PushMaterial {
  65830. private _diffuseTexture;
  65831. diffuseTexture: BABYLON.BaseTexture;
  65832. noiseTexture: BABYLON.BaseTexture;
  65833. fogColor: BABYLON.Color3;
  65834. speed: number;
  65835. movingSpeed: number;
  65836. lowFrequencySpeed: number;
  65837. fogDensity: number;
  65838. private _lastTime;
  65839. diffuseColor: BABYLON.Color3;
  65840. private _disableLighting;
  65841. disableLighting: boolean;
  65842. private _unlit;
  65843. unlit: boolean;
  65844. private _maxSimultaneousLights;
  65845. maxSimultaneousLights: number;
  65846. private _scaledDiffuse;
  65847. private _renderId;
  65848. constructor(name: string, scene: BABYLON.Scene);
  65849. needAlphaBlending(): boolean;
  65850. needAlphaTesting(): boolean;
  65851. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65852. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65853. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65854. getAnimatables(): BABYLON.IAnimatable[];
  65855. getActiveTextures(): BABYLON.BaseTexture[];
  65856. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65857. dispose(forceDisposeEffect?: boolean): void;
  65858. clone(name: string): LavaMaterial;
  65859. serialize(): any;
  65860. getClassName(): string;
  65861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  65862. }
  65863. }
  65864. declare module BABYLON {
  65865. /** @hidden */
  65866. export var mixPixelShader: {
  65867. name: string;
  65868. shader: string;
  65869. };
  65870. }
  65871. declare module BABYLON {
  65872. /** @hidden */
  65873. export var mixVertexShader: {
  65874. name: string;
  65875. shader: string;
  65876. };
  65877. }
  65878. declare module BABYLON {
  65879. export class MixMaterial extends BABYLON.PushMaterial {
  65880. /**
  65881. * Mix textures
  65882. */
  65883. private _mixTexture1;
  65884. mixTexture1: BABYLON.BaseTexture;
  65885. private _mixTexture2;
  65886. mixTexture2: BABYLON.BaseTexture;
  65887. /**
  65888. * Diffuse textures
  65889. */
  65890. private _diffuseTexture1;
  65891. diffuseTexture1: BABYLON.Texture;
  65892. private _diffuseTexture2;
  65893. diffuseTexture2: BABYLON.Texture;
  65894. private _diffuseTexture3;
  65895. diffuseTexture3: BABYLON.Texture;
  65896. private _diffuseTexture4;
  65897. diffuseTexture4: BABYLON.Texture;
  65898. private _diffuseTexture5;
  65899. diffuseTexture5: BABYLON.Texture;
  65900. private _diffuseTexture6;
  65901. diffuseTexture6: BABYLON.Texture;
  65902. private _diffuseTexture7;
  65903. diffuseTexture7: BABYLON.Texture;
  65904. private _diffuseTexture8;
  65905. diffuseTexture8: BABYLON.Texture;
  65906. /**
  65907. * Uniforms
  65908. */
  65909. diffuseColor: BABYLON.Color3;
  65910. specularColor: BABYLON.Color3;
  65911. specularPower: number;
  65912. private _disableLighting;
  65913. disableLighting: boolean;
  65914. private _maxSimultaneousLights;
  65915. maxSimultaneousLights: number;
  65916. private _renderId;
  65917. constructor(name: string, scene: BABYLON.Scene);
  65918. needAlphaBlending(): boolean;
  65919. needAlphaTesting(): boolean;
  65920. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65921. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65922. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65923. getAnimatables(): BABYLON.IAnimatable[];
  65924. getActiveTextures(): BABYLON.BaseTexture[];
  65925. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65926. dispose(forceDisposeEffect?: boolean): void;
  65927. clone(name: string): MixMaterial;
  65928. serialize(): any;
  65929. getClassName(): string;
  65930. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  65931. }
  65932. }
  65933. declare module BABYLON {
  65934. /** @hidden */
  65935. export var normalPixelShader: {
  65936. name: string;
  65937. shader: string;
  65938. };
  65939. }
  65940. declare module BABYLON {
  65941. /** @hidden */
  65942. export var normalVertexShader: {
  65943. name: string;
  65944. shader: string;
  65945. };
  65946. }
  65947. declare module BABYLON {
  65948. export class NormalMaterial extends BABYLON.PushMaterial {
  65949. private _diffuseTexture;
  65950. diffuseTexture: BABYLON.BaseTexture;
  65951. diffuseColor: BABYLON.Color3;
  65952. private _disableLighting;
  65953. disableLighting: boolean;
  65954. private _maxSimultaneousLights;
  65955. maxSimultaneousLights: number;
  65956. private _renderId;
  65957. constructor(name: string, scene: BABYLON.Scene);
  65958. needAlphaBlending(): boolean;
  65959. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  65960. needAlphaTesting(): boolean;
  65961. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65962. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65963. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65964. getAnimatables(): BABYLON.IAnimatable[];
  65965. getActiveTextures(): BABYLON.BaseTexture[];
  65966. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65967. dispose(forceDisposeEffect?: boolean): void;
  65968. clone(name: string): NormalMaterial;
  65969. serialize(): any;
  65970. getClassName(): string;
  65971. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  65972. }
  65973. }
  65974. declare module BABYLON {
  65975. /** @hidden */
  65976. export var shadowOnlyPixelShader: {
  65977. name: string;
  65978. shader: string;
  65979. };
  65980. }
  65981. declare module BABYLON {
  65982. /** @hidden */
  65983. export var shadowOnlyVertexShader: {
  65984. name: string;
  65985. shader: string;
  65986. };
  65987. }
  65988. declare module BABYLON {
  65989. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  65990. private _renderId;
  65991. private _activeLight;
  65992. constructor(name: string, scene: BABYLON.Scene);
  65993. shadowColor: BABYLON.Color3;
  65994. needAlphaBlending(): boolean;
  65995. needAlphaTesting(): boolean;
  65996. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65997. activeLight: BABYLON.IShadowLight;
  65998. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65999. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66000. clone(name: string): ShadowOnlyMaterial;
  66001. serialize(): any;
  66002. getClassName(): string;
  66003. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  66004. }
  66005. }
  66006. declare module BABYLON {
  66007. /** @hidden */
  66008. export var simplePixelShader: {
  66009. name: string;
  66010. shader: string;
  66011. };
  66012. }
  66013. declare module BABYLON {
  66014. /** @hidden */
  66015. export var simpleVertexShader: {
  66016. name: string;
  66017. shader: string;
  66018. };
  66019. }
  66020. declare module BABYLON {
  66021. export class SimpleMaterial extends BABYLON.PushMaterial {
  66022. private _diffuseTexture;
  66023. diffuseTexture: BABYLON.BaseTexture;
  66024. diffuseColor: BABYLON.Color3;
  66025. private _disableLighting;
  66026. disableLighting: boolean;
  66027. private _maxSimultaneousLights;
  66028. maxSimultaneousLights: number;
  66029. private _renderId;
  66030. constructor(name: string, scene: BABYLON.Scene);
  66031. needAlphaBlending(): boolean;
  66032. needAlphaTesting(): boolean;
  66033. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66036. getAnimatables(): BABYLON.IAnimatable[];
  66037. getActiveTextures(): BABYLON.BaseTexture[];
  66038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66039. dispose(forceDisposeEffect?: boolean): void;
  66040. clone(name: string): SimpleMaterial;
  66041. serialize(): any;
  66042. getClassName(): string;
  66043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  66044. }
  66045. }
  66046. declare module BABYLON {
  66047. /** @hidden */
  66048. export var skyPixelShader: {
  66049. name: string;
  66050. shader: string;
  66051. };
  66052. }
  66053. declare module BABYLON {
  66054. /** @hidden */
  66055. export var skyVertexShader: {
  66056. name: string;
  66057. shader: string;
  66058. };
  66059. }
  66060. declare module BABYLON {
  66061. /**
  66062. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  66063. * @see https://doc.babylonjs.com/extensions/sky
  66064. */
  66065. export class SkyMaterial extends BABYLON.PushMaterial {
  66066. /**
  66067. * Defines the overall luminance of sky in interval ]0, 1[.
  66068. */
  66069. luminance: number;
  66070. /**
  66071. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  66072. */
  66073. turbidity: number;
  66074. /**
  66075. * Defines the sky appearance (light intensity).
  66076. */
  66077. rayleigh: number;
  66078. /**
  66079. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  66080. */
  66081. mieCoefficient: number;
  66082. /**
  66083. * Defines the amount of haze particles following the Mie scattering theory.
  66084. */
  66085. mieDirectionalG: number;
  66086. /**
  66087. * Defines the distance of the sun according to the active scene camera.
  66088. */
  66089. distance: number;
  66090. /**
  66091. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  66092. * "inclined".
  66093. */
  66094. inclination: number;
  66095. /**
  66096. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  66097. * an object direction and a reference direction.
  66098. */
  66099. azimuth: number;
  66100. /**
  66101. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  66102. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  66103. */
  66104. sunPosition: BABYLON.Vector3;
  66105. /**
  66106. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  66107. * .sunPosition property.
  66108. */
  66109. useSunPosition: boolean;
  66110. /**
  66111. * Defines an offset vector used to get a horizon offset.
  66112. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  66113. */
  66114. cameraOffset: BABYLON.Vector3;
  66115. private _cameraPosition;
  66116. private _renderId;
  66117. /**
  66118. * Instantiates a new sky material.
  66119. * This material allows to create dynamic and texture free
  66120. * effects for skyboxes by taking care of the atmosphere state.
  66121. * @see https://doc.babylonjs.com/extensions/sky
  66122. * @param name Define the name of the material in the scene
  66123. * @param scene Define the scene the material belong to
  66124. */
  66125. constructor(name: string, scene: BABYLON.Scene);
  66126. /**
  66127. * Specifies if the material will require alpha blending
  66128. * @returns a boolean specifying if alpha blending is needed
  66129. */
  66130. needAlphaBlending(): boolean;
  66131. /**
  66132. * Specifies if this material should be rendered in alpha test mode
  66133. * @returns false as the sky material doesn't need alpha testing.
  66134. */
  66135. needAlphaTesting(): boolean;
  66136. /**
  66137. * Get the texture used for alpha test purpose.
  66138. * @returns null as the sky material has no texture.
  66139. */
  66140. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66141. /**
  66142. * Get if the submesh is ready to be used and all its information available.
  66143. * Child classes can use it to update shaders
  66144. * @param mesh defines the mesh to check
  66145. * @param subMesh defines which submesh to check
  66146. * @param useInstances specifies that instances should be used
  66147. * @returns a boolean indicating that the submesh is ready or not
  66148. */
  66149. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66150. /**
  66151. * Binds the submesh to this material by preparing the effect and shader to draw
  66152. * @param world defines the world transformation matrix
  66153. * @param mesh defines the mesh containing the submesh
  66154. * @param subMesh defines the submesh to bind the material to
  66155. */
  66156. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66157. /**
  66158. * Get the list of animatables in the material.
  66159. * @returns the list of animatables object used in the material
  66160. */
  66161. getAnimatables(): BABYLON.IAnimatable[];
  66162. /**
  66163. * Disposes the material
  66164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66165. */
  66166. dispose(forceDisposeEffect?: boolean): void;
  66167. /**
  66168. * Makes a duplicate of the material, and gives it a new name
  66169. * @param name defines the new name for the duplicated material
  66170. * @returns the cloned material
  66171. */
  66172. clone(name: string): SkyMaterial;
  66173. /**
  66174. * Serializes this material in a JSON representation
  66175. * @returns the serialized material object
  66176. */
  66177. serialize(): any;
  66178. /**
  66179. * Gets the current class name of the material e.g. "SkyMaterial"
  66180. * Mainly use in serialization.
  66181. * @returns the class name
  66182. */
  66183. getClassName(): string;
  66184. /**
  66185. * Creates a sky material from parsed material data
  66186. * @param source defines the JSON representation of the material
  66187. * @param scene defines the hosting scene
  66188. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66189. * @returns a new sky material
  66190. */
  66191. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  66192. }
  66193. }
  66194. declare module BABYLON {
  66195. /** @hidden */
  66196. export var terrainPixelShader: {
  66197. name: string;
  66198. shader: string;
  66199. };
  66200. }
  66201. declare module BABYLON {
  66202. /** @hidden */
  66203. export var terrainVertexShader: {
  66204. name: string;
  66205. shader: string;
  66206. };
  66207. }
  66208. declare module BABYLON {
  66209. export class TerrainMaterial extends BABYLON.PushMaterial {
  66210. private _mixTexture;
  66211. mixTexture: BABYLON.BaseTexture;
  66212. private _diffuseTexture1;
  66213. diffuseTexture1: BABYLON.Texture;
  66214. private _diffuseTexture2;
  66215. diffuseTexture2: BABYLON.Texture;
  66216. private _diffuseTexture3;
  66217. diffuseTexture3: BABYLON.Texture;
  66218. private _bumpTexture1;
  66219. bumpTexture1: BABYLON.Texture;
  66220. private _bumpTexture2;
  66221. bumpTexture2: BABYLON.Texture;
  66222. private _bumpTexture3;
  66223. bumpTexture3: BABYLON.Texture;
  66224. diffuseColor: BABYLON.Color3;
  66225. specularColor: BABYLON.Color3;
  66226. specularPower: number;
  66227. private _disableLighting;
  66228. disableLighting: boolean;
  66229. private _maxSimultaneousLights;
  66230. maxSimultaneousLights: number;
  66231. private _renderId;
  66232. constructor(name: string, scene: BABYLON.Scene);
  66233. needAlphaBlending(): boolean;
  66234. needAlphaTesting(): boolean;
  66235. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66236. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66237. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66238. getAnimatables(): BABYLON.IAnimatable[];
  66239. getActiveTextures(): BABYLON.BaseTexture[];
  66240. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66241. dispose(forceDisposeEffect?: boolean): void;
  66242. clone(name: string): TerrainMaterial;
  66243. serialize(): any;
  66244. getClassName(): string;
  66245. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  66246. }
  66247. }
  66248. declare module BABYLON {
  66249. /** @hidden */
  66250. export var triplanarPixelShader: {
  66251. name: string;
  66252. shader: string;
  66253. };
  66254. }
  66255. declare module BABYLON {
  66256. /** @hidden */
  66257. export var triplanarVertexShader: {
  66258. name: string;
  66259. shader: string;
  66260. };
  66261. }
  66262. declare module BABYLON {
  66263. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  66264. mixTexture: BABYLON.BaseTexture;
  66265. private _diffuseTextureX;
  66266. diffuseTextureX: BABYLON.BaseTexture;
  66267. private _diffuseTextureY;
  66268. diffuseTextureY: BABYLON.BaseTexture;
  66269. private _diffuseTextureZ;
  66270. diffuseTextureZ: BABYLON.BaseTexture;
  66271. private _normalTextureX;
  66272. normalTextureX: BABYLON.BaseTexture;
  66273. private _normalTextureY;
  66274. normalTextureY: BABYLON.BaseTexture;
  66275. private _normalTextureZ;
  66276. normalTextureZ: BABYLON.BaseTexture;
  66277. tileSize: number;
  66278. diffuseColor: BABYLON.Color3;
  66279. specularColor: BABYLON.Color3;
  66280. specularPower: number;
  66281. private _disableLighting;
  66282. disableLighting: boolean;
  66283. private _maxSimultaneousLights;
  66284. maxSimultaneousLights: number;
  66285. private _renderId;
  66286. constructor(name: string, scene: BABYLON.Scene);
  66287. needAlphaBlending(): boolean;
  66288. needAlphaTesting(): boolean;
  66289. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66290. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66291. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66292. getAnimatables(): BABYLON.IAnimatable[];
  66293. getActiveTextures(): BABYLON.BaseTexture[];
  66294. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66295. dispose(forceDisposeEffect?: boolean): void;
  66296. clone(name: string): TriPlanarMaterial;
  66297. serialize(): any;
  66298. getClassName(): string;
  66299. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  66300. }
  66301. }
  66302. declare module BABYLON {
  66303. /** @hidden */
  66304. export var waterPixelShader: {
  66305. name: string;
  66306. shader: string;
  66307. };
  66308. }
  66309. declare module BABYLON {
  66310. /** @hidden */
  66311. export var waterVertexShader: {
  66312. name: string;
  66313. shader: string;
  66314. };
  66315. }
  66316. declare module BABYLON {
  66317. export class WaterMaterial extends BABYLON.PushMaterial {
  66318. renderTargetSize: BABYLON.Vector2;
  66319. private _bumpTexture;
  66320. bumpTexture: BABYLON.BaseTexture;
  66321. diffuseColor: BABYLON.Color3;
  66322. specularColor: BABYLON.Color3;
  66323. specularPower: number;
  66324. private _disableLighting;
  66325. disableLighting: boolean;
  66326. private _maxSimultaneousLights;
  66327. maxSimultaneousLights: number;
  66328. /**
  66329. * @param {number}: Represents the wind force
  66330. */
  66331. windForce: number;
  66332. /**
  66333. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  66334. */
  66335. windDirection: BABYLON.Vector2;
  66336. /**
  66337. * @param {number}: Wave height, represents the height of the waves
  66338. */
  66339. waveHeight: number;
  66340. /**
  66341. * @param {number}: Bump height, represents the bump height related to the bump map
  66342. */
  66343. bumpHeight: number;
  66344. /**
  66345. * @param {boolean}: Add a smaller moving bump to less steady waves.
  66346. */
  66347. private _bumpSuperimpose;
  66348. bumpSuperimpose: boolean;
  66349. /**
  66350. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  66351. */
  66352. private _fresnelSeparate;
  66353. fresnelSeparate: boolean;
  66354. /**
  66355. * @param {boolean}: bump Waves modify the reflection.
  66356. */
  66357. private _bumpAffectsReflection;
  66358. bumpAffectsReflection: boolean;
  66359. /**
  66360. * @param {number}: The water color blended with the refraction (near)
  66361. */
  66362. waterColor: BABYLON.Color3;
  66363. /**
  66364. * @param {number}: The blend factor related to the water color
  66365. */
  66366. colorBlendFactor: number;
  66367. /**
  66368. * @param {number}: The water color blended with the reflection (far)
  66369. */
  66370. waterColor2: BABYLON.Color3;
  66371. /**
  66372. * @param {number}: The blend factor related to the water color (reflection, far)
  66373. */
  66374. colorBlendFactor2: number;
  66375. /**
  66376. * @param {number}: Represents the maximum length of a wave
  66377. */
  66378. waveLength: number;
  66379. /**
  66380. * @param {number}: Defines the waves speed
  66381. */
  66382. waveSpeed: number;
  66383. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  66384. private _mesh;
  66385. private _refractionRTT;
  66386. private _reflectionRTT;
  66387. private _reflectionTransform;
  66388. private _lastTime;
  66389. private _lastDeltaTime;
  66390. private _renderId;
  66391. private _useLogarithmicDepth;
  66392. private _waitingRenderList;
  66393. /**
  66394. * Gets a boolean indicating that current material needs to register RTT
  66395. */
  66396. readonly hasRenderTargetTextures: boolean;
  66397. /**
  66398. * Constructor
  66399. */
  66400. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  66401. useLogarithmicDepth: boolean;
  66402. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  66403. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  66404. addToRenderList(node: any): void;
  66405. enableRenderTargets(enable: boolean): void;
  66406. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  66407. readonly renderTargetsEnabled: boolean;
  66408. needAlphaBlending(): boolean;
  66409. needAlphaTesting(): boolean;
  66410. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66411. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66412. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66413. private _createRenderTargets;
  66414. getAnimatables(): BABYLON.IAnimatable[];
  66415. getActiveTextures(): BABYLON.BaseTexture[];
  66416. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66417. dispose(forceDisposeEffect?: boolean): void;
  66418. clone(name: string): WaterMaterial;
  66419. serialize(): any;
  66420. getClassName(): string;
  66421. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  66422. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  66423. }
  66424. }
  66425. declare module BABYLON {
  66426. /** @hidden */
  66427. export var asciiartPixelShader: {
  66428. name: string;
  66429. shader: string;
  66430. };
  66431. }
  66432. declare module BABYLON {
  66433. /**
  66434. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  66435. *
  66436. * It basically takes care rendering the font front the given font size to a texture.
  66437. * This is used later on in the postprocess.
  66438. */
  66439. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  66440. private _font;
  66441. private _text;
  66442. private _charSize;
  66443. /**
  66444. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  66445. */
  66446. readonly charSize: number;
  66447. /**
  66448. * Create a new instance of the Ascii Art FontTexture class
  66449. * @param name the name of the texture
  66450. * @param font the font to use, use the W3C CSS notation
  66451. * @param text the caracter set to use in the rendering.
  66452. * @param scene the scene that owns the texture
  66453. */
  66454. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  66455. /**
  66456. * Gets the max char width of a font.
  66457. * @param font the font to use, use the W3C CSS notation
  66458. * @return the max char width
  66459. */
  66460. private getFontWidth;
  66461. /**
  66462. * Gets the max char height of a font.
  66463. * @param font the font to use, use the W3C CSS notation
  66464. * @return the max char height
  66465. */
  66466. private getFontHeight;
  66467. /**
  66468. * Clones the current AsciiArtTexture.
  66469. * @return the clone of the texture.
  66470. */
  66471. clone(): AsciiArtFontTexture;
  66472. /**
  66473. * Parses a json object representing the texture and returns an instance of it.
  66474. * @param source the source JSON representation
  66475. * @param scene the scene to create the texture for
  66476. * @return the parsed texture
  66477. */
  66478. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  66479. }
  66480. /**
  66481. * Option available in the Ascii Art Post Process.
  66482. */
  66483. export interface IAsciiArtPostProcessOptions {
  66484. /**
  66485. * The font to use following the w3c font definition.
  66486. */
  66487. font?: string;
  66488. /**
  66489. * The character set to use in the postprocess.
  66490. */
  66491. characterSet?: string;
  66492. /**
  66493. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  66494. * This number is defined between 0 and 1;
  66495. */
  66496. mixToTile?: number;
  66497. /**
  66498. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  66499. * This number is defined between 0 and 1;
  66500. */
  66501. mixToNormal?: number;
  66502. }
  66503. /**
  66504. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  66505. *
  66506. * Simmply add it to your scene and let the nerd that lives in you have fun.
  66507. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  66508. */
  66509. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  66510. /**
  66511. * The font texture used to render the char in the post process.
  66512. */
  66513. private _asciiArtFontTexture;
  66514. /**
  66515. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  66516. * This number is defined between 0 and 1;
  66517. */
  66518. mixToTile: number;
  66519. /**
  66520. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  66521. * This number is defined between 0 and 1;
  66522. */
  66523. mixToNormal: number;
  66524. /**
  66525. * Instantiates a new Ascii Art Post Process.
  66526. * @param name the name to give to the postprocess
  66527. * @camera the camera to apply the post process to.
  66528. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  66529. */
  66530. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  66531. }
  66532. }
  66533. declare module BABYLON {
  66534. /** @hidden */
  66535. export var digitalrainPixelShader: {
  66536. name: string;
  66537. shader: string;
  66538. };
  66539. }
  66540. declare module BABYLON {
  66541. /**
  66542. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  66543. *
  66544. * It basically takes care rendering the font front the given font size to a texture.
  66545. * This is used later on in the postprocess.
  66546. */
  66547. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  66548. private _font;
  66549. private _text;
  66550. private _charSize;
  66551. /**
  66552. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  66553. */
  66554. readonly charSize: number;
  66555. /**
  66556. * Create a new instance of the Digital Rain FontTexture class
  66557. * @param name the name of the texture
  66558. * @param font the font to use, use the W3C CSS notation
  66559. * @param text the caracter set to use in the rendering.
  66560. * @param scene the scene that owns the texture
  66561. */
  66562. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  66563. /**
  66564. * Gets the max char width of a font.
  66565. * @param font the font to use, use the W3C CSS notation
  66566. * @return the max char width
  66567. */
  66568. private getFontWidth;
  66569. /**
  66570. * Gets the max char height of a font.
  66571. * @param font the font to use, use the W3C CSS notation
  66572. * @return the max char height
  66573. */
  66574. private getFontHeight;
  66575. /**
  66576. * Clones the current DigitalRainFontTexture.
  66577. * @return the clone of the texture.
  66578. */
  66579. clone(): DigitalRainFontTexture;
  66580. /**
  66581. * Parses a json object representing the texture and returns an instance of it.
  66582. * @param source the source JSON representation
  66583. * @param scene the scene to create the texture for
  66584. * @return the parsed texture
  66585. */
  66586. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  66587. }
  66588. /**
  66589. * Option available in the Digital Rain Post Process.
  66590. */
  66591. export interface IDigitalRainPostProcessOptions {
  66592. /**
  66593. * The font to use following the w3c font definition.
  66594. */
  66595. font?: string;
  66596. /**
  66597. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  66598. * This number is defined between 0 and 1;
  66599. */
  66600. mixToTile?: number;
  66601. /**
  66602. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  66603. * This number is defined between 0 and 1;
  66604. */
  66605. mixToNormal?: number;
  66606. }
  66607. /**
  66608. * DigitalRainPostProcess helps rendering everithing in digital rain.
  66609. *
  66610. * Simmply add it to your scene and let the nerd that lives in you have fun.
  66611. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  66612. */
  66613. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  66614. /**
  66615. * The font texture used to render the char in the post process.
  66616. */
  66617. private _digitalRainFontTexture;
  66618. /**
  66619. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  66620. * This number is defined between 0 and 1;
  66621. */
  66622. mixToTile: number;
  66623. /**
  66624. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  66625. * This number is defined between 0 and 1;
  66626. */
  66627. mixToNormal: number;
  66628. /**
  66629. * Instantiates a new Digital Rain Post Process.
  66630. * @param name the name to give to the postprocess
  66631. * @camera the camera to apply the post process to.
  66632. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  66633. */
  66634. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  66635. }
  66636. }
  66637. declare module BABYLON {
  66638. /** @hidden */
  66639. export var oceanPostProcessPixelShader: {
  66640. name: string;
  66641. shader: string;
  66642. };
  66643. }
  66644. declare module BABYLON {
  66645. /**
  66646. * Option available in the Ocean Post Process.
  66647. */
  66648. export interface IOceanPostProcessOptions {
  66649. /**
  66650. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  66651. */
  66652. reflectionSize?: number | {
  66653. width: number;
  66654. height: number;
  66655. } | {
  66656. ratio: number;
  66657. };
  66658. /**
  66659. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  66660. */
  66661. refractionSize?: number | {
  66662. width: number;
  66663. height: number;
  66664. } | {
  66665. ratio: number;
  66666. };
  66667. }
  66668. /**
  66669. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  66670. *
  66671. * Simmply add it to your scene and let the nerd that lives in you have fun.
  66672. * Example usage:
  66673. * var pp = new OceanPostProcess("myOcean", camera);
  66674. * pp.reflectionEnabled = true;
  66675. * pp.refractionEnabled = true;
  66676. */
  66677. export class OceanPostProcess extends BABYLON.PostProcess {
  66678. /**
  66679. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  66680. */
  66681. /**
  66682. * Sets weither or not the real-time reflection is enabled on the ocean.
  66683. * Is set to true, the reflection mirror texture will be used as reflection texture.
  66684. */
  66685. reflectionEnabled: boolean;
  66686. /**
  66687. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  66688. */
  66689. /**
  66690. * Sets weither or not the real-time refraction is enabled on the ocean.
  66691. * Is set to true, the refraction render target texture will be used as refraction texture.
  66692. */
  66693. refractionEnabled: boolean;
  66694. /**
  66695. * Gets wether or not the post-processes is supported by the running hardware.
  66696. * This requires draw buffer supports.
  66697. */
  66698. readonly isSupported: boolean;
  66699. /**
  66700. * This is the reflection mirror texture used to display reflections on the ocean.
  66701. * By default, render list is empty.
  66702. */
  66703. reflectionTexture: BABYLON.MirrorTexture;
  66704. /**
  66705. * This is the refraction render target texture used to display refraction on the ocean.
  66706. * By default, render list is empty.
  66707. */
  66708. refractionTexture: BABYLON.RenderTargetTexture;
  66709. private _time;
  66710. private _cameraRotation;
  66711. private _cameraViewMatrix;
  66712. private _reflectionEnabled;
  66713. private _refractionEnabled;
  66714. private _geometryRenderer;
  66715. /**
  66716. * Instantiates a new Ocean Post Process.
  66717. * @param name the name to give to the postprocess.
  66718. * @camera the camera to apply the post process to.
  66719. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  66720. */
  66721. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  66722. /**
  66723. * Returns the appropriate defines according to the current configuration.
  66724. */
  66725. private _getDefines;
  66726. /**
  66727. * Computes the current camera rotation as the shader requires a camera rotation.
  66728. */
  66729. private _computeCameraRotation;
  66730. }
  66731. }
  66732. declare module BABYLON {
  66733. /** @hidden */
  66734. export var brickProceduralTexturePixelShader: {
  66735. name: string;
  66736. shader: string;
  66737. };
  66738. }
  66739. declare module BABYLON {
  66740. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  66741. private _numberOfBricksHeight;
  66742. private _numberOfBricksWidth;
  66743. private _jointColor;
  66744. private _brickColor;
  66745. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66746. updateShaderUniforms(): void;
  66747. numberOfBricksHeight: number;
  66748. numberOfBricksWidth: number;
  66749. jointColor: BABYLON.Color3;
  66750. brickColor: BABYLON.Color3;
  66751. /**
  66752. * Serializes this brick procedural texture
  66753. * @returns a serialized brick procedural texture object
  66754. */
  66755. serialize(): any;
  66756. /**
  66757. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  66758. * @param parsedTexture defines parsed texture data
  66759. * @param scene defines the current scene
  66760. * @param rootUrl defines the root URL containing brick procedural texture information
  66761. * @returns a parsed Brick Procedural BABYLON.Texture
  66762. */
  66763. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  66764. }
  66765. }
  66766. declare module BABYLON {
  66767. /** @hidden */
  66768. export var cloudProceduralTexturePixelShader: {
  66769. name: string;
  66770. shader: string;
  66771. };
  66772. }
  66773. declare module BABYLON {
  66774. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  66775. private _skyColor;
  66776. private _cloudColor;
  66777. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66778. updateShaderUniforms(): void;
  66779. skyColor: BABYLON.Color4;
  66780. cloudColor: BABYLON.Color4;
  66781. /**
  66782. * Serializes this cloud procedural texture
  66783. * @returns a serialized cloud procedural texture object
  66784. */
  66785. serialize(): any;
  66786. /**
  66787. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  66788. * @param parsedTexture defines parsed texture data
  66789. * @param scene defines the current scene
  66790. * @param rootUrl defines the root URL containing cloud procedural texture information
  66791. * @returns a parsed Cloud Procedural BABYLON.Texture
  66792. */
  66793. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /** @hidden */
  66798. export var fireProceduralTexturePixelShader: {
  66799. name: string;
  66800. shader: string;
  66801. };
  66802. }
  66803. declare module BABYLON {
  66804. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  66805. private _time;
  66806. private _speed;
  66807. private _autoGenerateTime;
  66808. private _fireColors;
  66809. private _alphaThreshold;
  66810. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66811. updateShaderUniforms(): void;
  66812. render(useCameraPostProcess?: boolean): void;
  66813. static readonly PurpleFireColors: BABYLON.Color3[];
  66814. static readonly GreenFireColors: BABYLON.Color3[];
  66815. static readonly RedFireColors: BABYLON.Color3[];
  66816. static readonly BlueFireColors: BABYLON.Color3[];
  66817. autoGenerateTime: boolean;
  66818. fireColors: BABYLON.Color3[];
  66819. time: number;
  66820. speed: BABYLON.Vector2;
  66821. alphaThreshold: number;
  66822. /**
  66823. * Serializes this fire procedural texture
  66824. * @returns a serialized fire procedural texture object
  66825. */
  66826. serialize(): any;
  66827. /**
  66828. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  66829. * @param parsedTexture defines parsed texture data
  66830. * @param scene defines the current scene
  66831. * @param rootUrl defines the root URL containing fire procedural texture information
  66832. * @returns a parsed Fire Procedural BABYLON.Texture
  66833. */
  66834. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  66835. }
  66836. }
  66837. declare module BABYLON {
  66838. /** @hidden */
  66839. export var grassProceduralTexturePixelShader: {
  66840. name: string;
  66841. shader: string;
  66842. };
  66843. }
  66844. declare module BABYLON {
  66845. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  66846. private _grassColors;
  66847. private _groundColor;
  66848. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66849. updateShaderUniforms(): void;
  66850. grassColors: BABYLON.Color3[];
  66851. groundColor: BABYLON.Color3;
  66852. /**
  66853. * Serializes this grass procedural texture
  66854. * @returns a serialized grass procedural texture object
  66855. */
  66856. serialize(): any;
  66857. /**
  66858. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  66859. * @param parsedTexture defines parsed texture data
  66860. * @param scene defines the current scene
  66861. * @param rootUrl defines the root URL containing grass procedural texture information
  66862. * @returns a parsed Grass Procedural BABYLON.Texture
  66863. */
  66864. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  66865. }
  66866. }
  66867. declare module BABYLON {
  66868. /** @hidden */
  66869. export var marbleProceduralTexturePixelShader: {
  66870. name: string;
  66871. shader: string;
  66872. };
  66873. }
  66874. declare module BABYLON {
  66875. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  66876. private _numberOfTilesHeight;
  66877. private _numberOfTilesWidth;
  66878. private _amplitude;
  66879. private _jointColor;
  66880. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66881. updateShaderUniforms(): void;
  66882. numberOfTilesHeight: number;
  66883. amplitude: number;
  66884. numberOfTilesWidth: number;
  66885. jointColor: BABYLON.Color3;
  66886. /**
  66887. * Serializes this marble procedural texture
  66888. * @returns a serialized marble procedural texture object
  66889. */
  66890. serialize(): any;
  66891. /**
  66892. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  66893. * @param parsedTexture defines parsed texture data
  66894. * @param scene defines the current scene
  66895. * @param rootUrl defines the root URL containing marble procedural texture information
  66896. * @returns a parsed Marble Procedural BABYLON.Texture
  66897. */
  66898. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  66899. }
  66900. }
  66901. declare module BABYLON {
  66902. /** @hidden */
  66903. export var normalMapProceduralTexturePixelShader: {
  66904. name: string;
  66905. shader: string;
  66906. };
  66907. }
  66908. declare module BABYLON {
  66909. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  66910. private _baseTexture;
  66911. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66912. updateShaderUniforms(): void;
  66913. render(useCameraPostProcess?: boolean): void;
  66914. resize(size: any, generateMipMaps: any): void;
  66915. baseTexture: BABYLON.Texture;
  66916. /**
  66917. * Serializes this normal map procedural texture
  66918. * @returns a serialized normal map procedural texture object
  66919. */
  66920. serialize(): any;
  66921. /**
  66922. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  66923. * @param parsedTexture defines parsed texture data
  66924. * @param scene defines the current scene
  66925. * @param rootUrl defines the root URL containing normal map procedural texture information
  66926. * @returns a parsed Normal Map Procedural BABYLON.Texture
  66927. */
  66928. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  66929. }
  66930. }
  66931. declare module BABYLON {
  66932. /** @hidden */
  66933. export var perlinNoiseProceduralTexturePixelShader: {
  66934. name: string;
  66935. shader: string;
  66936. };
  66937. }
  66938. declare module BABYLON {
  66939. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  66940. time: number;
  66941. timeScale: number;
  66942. translationSpeed: number;
  66943. private _currentTranslation;
  66944. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66945. updateShaderUniforms(): void;
  66946. render(useCameraPostProcess?: boolean): void;
  66947. resize(size: any, generateMipMaps: any): void;
  66948. /**
  66949. * Serializes this perlin noise procedural texture
  66950. * @returns a serialized perlin noise procedural texture object
  66951. */
  66952. serialize(): any;
  66953. /**
  66954. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  66955. * @param parsedTexture defines parsed texture data
  66956. * @param scene defines the current scene
  66957. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  66958. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  66959. */
  66960. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  66961. }
  66962. }
  66963. declare module BABYLON {
  66964. /** @hidden */
  66965. export var roadProceduralTexturePixelShader: {
  66966. name: string;
  66967. shader: string;
  66968. };
  66969. }
  66970. declare module BABYLON {
  66971. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  66972. private _roadColor;
  66973. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66974. updateShaderUniforms(): void;
  66975. roadColor: BABYLON.Color3;
  66976. /**
  66977. * Serializes this road procedural texture
  66978. * @returns a serialized road procedural texture object
  66979. */
  66980. serialize(): any;
  66981. /**
  66982. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  66983. * @param parsedTexture defines parsed texture data
  66984. * @param scene defines the current scene
  66985. * @param rootUrl defines the root URL containing road procedural texture information
  66986. * @returns a parsed Road Procedural BABYLON.Texture
  66987. */
  66988. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  66989. }
  66990. }
  66991. declare module BABYLON {
  66992. /** @hidden */
  66993. export var starfieldProceduralTexturePixelShader: {
  66994. name: string;
  66995. shader: string;
  66996. };
  66997. }
  66998. declare module BABYLON {
  66999. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  67000. private _time;
  67001. private _alpha;
  67002. private _beta;
  67003. private _zoom;
  67004. private _formuparam;
  67005. private _stepsize;
  67006. private _tile;
  67007. private _brightness;
  67008. private _darkmatter;
  67009. private _distfading;
  67010. private _saturation;
  67011. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67012. updateShaderUniforms(): void;
  67013. time: number;
  67014. alpha: number;
  67015. beta: number;
  67016. formuparam: number;
  67017. stepsize: number;
  67018. zoom: number;
  67019. tile: number;
  67020. brightness: number;
  67021. darkmatter: number;
  67022. distfading: number;
  67023. saturation: number;
  67024. /**
  67025. * Serializes this starfield procedural texture
  67026. * @returns a serialized starfield procedural texture object
  67027. */
  67028. serialize(): any;
  67029. /**
  67030. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  67031. * @param parsedTexture defines parsed texture data
  67032. * @param scene defines the current scene
  67033. * @param rootUrl defines the root URL containing startfield procedural texture information
  67034. * @returns a parsed Starfield Procedural BABYLON.Texture
  67035. */
  67036. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  67037. }
  67038. }
  67039. declare module BABYLON {
  67040. /** @hidden */
  67041. export var woodProceduralTexturePixelShader: {
  67042. name: string;
  67043. shader: string;
  67044. };
  67045. }
  67046. declare module BABYLON {
  67047. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  67048. private _ampScale;
  67049. private _woodColor;
  67050. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67051. updateShaderUniforms(): void;
  67052. ampScale: number;
  67053. woodColor: BABYLON.Color3;
  67054. /**
  67055. * Serializes this wood procedural texture
  67056. * @returns a serialized wood procedural texture object
  67057. */
  67058. serialize(): any;
  67059. /**
  67060. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  67061. * @param parsedTexture defines parsed texture data
  67062. * @param scene defines the current scene
  67063. * @param rootUrl defines the root URL containing wood procedural texture information
  67064. * @returns a parsed Wood Procedural BABYLON.Texture
  67065. */
  67066. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  67067. }
  67068. }